com.flat502.rox.server
Class XmlRpcServer

java.lang.Object
  extended by com.flat502.rox.processing.HttpRpcProcessor
      extended by com.flat502.rox.server.HttpRpcServer
          extended by com.flat502.rox.server.XmlRpcServer

public class XmlRpcServer
extends HttpRpcServer

This is the server-side XML-RPC interface.

This is a specialization of the HttpRpcServer.

An instance of this class will not actually bind to any addresses until Thread.start() is invoked.

Typical usage of this class is illustrated in the following sample:

 public class Handler implements SyncRequestHandler {
        public RpcResponse handleRequest(RpcCall call) {
                // Handle the call and return a response
        }
 }
 ...
 XmlRpcServer server = new XmlRpcServer(host, port);
 server.registerHandler(null, "^math\\.", new Handler());
 server.start();
 

In addition, this class supports asynchronous method handling and dynamic method discovery.

You're encouraged to read through the examples section.


Field Summary
 
Fields inherited from class com.flat502.rox.processing.HttpRpcProcessor
ALL_CIPHER_SUITES, ANON_CIPHER_SUITES
 
Constructor Summary
XmlRpcServer(java.net.InetAddress hostAddress, int port)
          Initialize an instance listening for connections on a specified local address.
XmlRpcServer(java.net.InetAddress hostAddress, int port, boolean useHttps)
          Initialize an instance listening for connections on a specified local address.
XmlRpcServer(java.net.InetAddress hostAddress, int port, boolean useHttps, AcceptPolicy acceptPolicy, ServerResourcePool workerPool)
          Initialize an instance listening for connections on a specified local address.
XmlRpcServer(java.net.InetAddress hostAddress, int port, boolean useHttps, AcceptPolicy acceptPolicy, ServerResourcePool workerPool, SSLConfiguration sslCfg)
           
XmlRpcServer(java.net.InetAddress hostAddress, int port, SSLConfiguration sslCfg)
           
XmlRpcServer(int port)
          Initialize an instance listening for connections on all local addresses.
 
Method Summary
 RequestHandler registerProxyingHandler(java.lang.String uri, java.lang.String method, java.lang.Object target)
          Register an XML-RPC aware ProxyingRequestHandler proxying the specified target object.
 void setUnmarshaller(MethodCallUnmarshaller unmarshaller)
          Configure the MethodResponseUnmarshaller instance to use when unmarshalling incoming XML-RPC method calls.
 
Methods inherited from class com.flat502.rox.server.HttpRpcServer
accept, deregisterResponseCoordinator, deregisterSocket, getReadBuffer, getServerName, getWriteBuffer, handleMessageException, handleProcessingException, handleSelectionKeyOperation, handleSSLHandshakeFinished, handleTimeout, initSelector, initSocketSSLEngine, isWriteQueued, newHttpResponse, newHttpResponse, newRpcCallContext, newWorkerPool, putWriteBuffer, read, registerAcceptPolicy, registerContentEncoding, registerHandler, registerHandler, registerHandler, registerHandler, registerHandler, registerHandler, registerHandler, registerHandler, registerRequestUnmarshaller, removeReadBuffer, removeReadBuffers, removeWriteBuffer, removeWriteBuffers, selectResponseEncoding, setEncodeResponses, setIdleClientTimeout, stopImpl, toHttpResponse, write
 
Methods inherited from class com.flat502.rox.processing.HttpRpcProcessor
addWorker, addWorkers, deregisterChannel, getQueue, getSocketSelector, getSSLConfiguration, getSSLSession, getTimer, getWorkerCount, initialize, isSharedWorkerPool, isStarted, newSSLSession, queueCancellation, queueRead, queueRegistration, queueWrite, queueWrite, registerChannel, registerProfiler, registerSocket, registerSSLSessionPolicy, removeWorker, setCipherSuitePattern, setSSLHandshakeTimeout, shouldUseHTTPS, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcServer

public XmlRpcServer(int port)
             throws java.io.IOException
Initialize an instance listening for connections on all local addresses.

HTTPS (SSL) and logging are disabled and no accept policy is installed.

Parameters:
port - The port to listen on.
Throws:
java.io.IOException - if an error occurs initializing the underlying server socket.

XmlRpcServer

public XmlRpcServer(java.net.InetAddress hostAddress,
                    int port)
             throws java.io.IOException
Initialize an instance listening for connections on a specified local address.

HTTPS (SSL) is disabled and no accept policy is installed.

Parameters:
hostAddress - The address to listen on. If this is null this instance will listen on all local addresses.
port - The port to listen on.
Throws:
java.io.IOException - if an error occurs initializing the underlying server socket.

XmlRpcServer

public XmlRpcServer(java.net.InetAddress hostAddress,
                    int port,
                    SSLConfiguration sslCfg)
             throws java.io.IOException
Throws:
java.io.IOException

XmlRpcServer

public XmlRpcServer(java.net.InetAddress hostAddress,
                    int port,
                    boolean useHttps)
             throws java.io.IOException
Initialize an instance listening for connections on a specified local address.

No accept policy is installed.

Parameters:
hostAddress - The address to listen on. If this is null this instance will listen on all local addresses.
port - The port to listen on.
Throws:
java.io.IOException - if an error occurs initializing the underlying server socket.

XmlRpcServer

public XmlRpcServer(java.net.InetAddress hostAddress,
                    int port,
                    boolean useHttps,
                    AcceptPolicy acceptPolicy,
                    ServerResourcePool workerPool)
             throws java.io.IOException
Initialize an instance listening for connections on a specified local address.

Parameters:
hostAddress - The address to listen on. If this is null this instance will listen on all local addresses.
port - The port to listen on.
useHttps - Indicates whether or not HTTPS (SSL) should be enabled.
acceptPolicy - The AcceptPolicy to apply. May be null.
workerPool - A shared ServerResourcePool instance from which resources (like timers and threads) should be drawn.
Throws:
java.io.IOException - if an error occurs initializing the underlying server socket.

XmlRpcServer

public XmlRpcServer(java.net.InetAddress hostAddress,
                    int port,
                    boolean useHttps,
                    AcceptPolicy acceptPolicy,
                    ServerResourcePool workerPool,
                    SSLConfiguration sslCfg)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

registerProxyingHandler

public RequestHandler registerProxyingHandler(java.lang.String uri,
                                              java.lang.String method,
                                              java.lang.Object target)
Register an XML-RPC aware ProxyingRequestHandler proxying the specified target object.

A SynchronousRequestHandler is registered for the specified URI. Method dispatch and request unmarshalling is described in the documentation for RpcMethodProxy.

Parameters:
uri - The URI for which this handler is responsible. null indicates all URIs.
method - A regular expression (see Pattern) to match method names on. Matching is performed as for the Matcher.find() method.
target - The object to delegate XML-RPC requests to.
Returns:
The RequestHandler that was registered.

setUnmarshaller

public void setUnmarshaller(MethodCallUnmarshaller unmarshaller)
Configure the MethodResponseUnmarshaller instance to use when unmarshalling incoming XML-RPC method calls.

Parameters:
unmarshaller - The new unmarshaller instance to use.
See Also:
DomMethodCallUnmarshaller, SaxMethodCallUnmarshaller