That's simple: Set the properties "enabledForExtensions" and "gzipCompressing". That said, note the following hints:
[top] |
That's as simple as enabling request compression: Set the properties "enabledForExtensions" and "gzipRequesting". That said, note the following hints:
[top] |
Yes, use the class TimingOutCallback.
// Wait for 10 seconds. TimingOutCallback callback = new TimingOutCallback(10 * 1000); XmlRpcClient client = new XmlRpcClient(url); client.executeAsync(methodName, params, callback); try { return callback.waitForResponse(); } catch (TimeoutException e) { System.out.println("No response from server."); } catch (Exception e) { System.out.println("Server returned an error message."); }
[top] |
You've got to use a special type factory. An example is contained in the documentation on {{{advanced.html}advanced topics}}.
[top] |
Set the property "enabledForExtensions". Note, that enabling the streaming mode doesn't mean, that all responses are served in streaming mode. It depends on the clients:
[top] |
Basically you've got to provide an AuthenticationHandler. See the {{{server.html}server documentation}} for an example.
[top] |
The PropertyHandlerMapping assumes, that request processors are POJO's (plain old java objects). However, this is not always desirable. For example, sometimes it is assumed that handlers need to be initialized by the servlet, which is configured through parameters.
The recommended solution is to configure your server with a special request processor factory.
public interface InitializableRequestProcessor { void init(HttpServlet pServlet) throws XmlRpcException; } public class MyXmlRpcServlet extends XmlRpcServlet { protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); RequestProcessorFactoryFactory factory = new RequestSpecificProcessorFactoryFactory(){ protected Object newRequestProcessor(Class pClass, XmlRpcRequest pRequest) { InitializableRequestProcessor proc = super.newRequestProcessor(pClass, pRequest); proc.init(MyXmlRpcServlet.this); return proc; } }; mapping.setRequestProcessorFactoryFactory(mapping); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; } }
[top] |
That's a similar question than the question on initializing handlers. The main difference is, that in this case you want to initialize the handler with any request. So, here's how to do it: First of all, we assume that all handlers will implement an interface RequestInitializableHandler. This interface has an init method, which is being called to receive an object with the clients IP address:
public class MyConfig extends XmlRpcHttpRequestConfigImpl { private String clientIpAddress; public String getClientIpAddress() { return clientIpAddress; } public void setClientIpAddress(String pClientIpAddress) { clientIpAddress = pClientIpAddress; } } public interface RequestInitializableRequestProcessor { public void init(MyConfig pConfig); } public class MyXmlRpcServlet extends XmlRpcServlet { protected XmlRpcServletServer newXmlRpcServer(ServletConfig pConfig) throws XmlRpcException { return new XmlRpcServletServer(){ protected XmlRpcHttpRequestConfigImpl newConfig(HttpServletRequest pRequest) { MyConfig config = new MyConfig(); config.setClientIpAddress(pRequest.getRemoteAddr()); return config; } }; } protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = super.newPropertyHandlerMapping(url); RequestProcessorFactoryFactory factory = new RequestSpecificProcessorFactoryFactory(){ protected Object newRequestProcessor(Class pClass, XmlRpcRequest pRequest) { RequestInitializableRequestProcessor proc = (RequestInitializableRequestProcessor) super.newRequestProcessor(pClass, pRequest); proc.init(pRequest.getConfig()); return proc; } }; mapping.setRequestProcessorFactoryFactory(mapping); return mapping; } }
[top] |
[top] |