Class RMIAsyncServerDemo

  extended by com.flat502.rox.marshal.UnmarshallerAid
      extended by com.flat502.rox.marshal.MethodCallUnmarshallerAid
          extended by com.flat502.rox.demo.RMIAsyncServerDemo
All Implemented Interfaces:
RMIServerInterface, AsynchronousRequestHandler, RequestHandler

public class RMIAsyncServerDemo
extends MethodCallUnmarshallerAid
implements AsynchronousRequestHandler, RMIServerInterface

A demo server illustrating the ProxyingRequestHandler class.

Constructor Summary
Method Summary
 java.util.Date getDate()
          Get the current date and time.
 FieldNameCodec getFieldNameCodec(java.lang.String methodName)
          Invoked when a method call unmarshaller is required.
 java.lang.Class getType(java.lang.String methodName, int index)
          An implementation should return a Class instance representing the type a complex parameter value (a struct or an array) at the given index should be unmarshalled as.
 java.lang.String getVersionInfo(boolean verbose)
          Fetch a version string.
 void handleRequest(RpcCall call, RpcCallContext context, ResponseChannel rspChannel)
          Invoked to handle a method call.
static void main(java.lang.String[] args)
          Start an instance of this demo server.
 int sum(int[] list)
          Sums an array of integers;
Methods inherited from class com.flat502.rox.marshal.UnmarshallerAid
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public RMIAsyncServerDemo()
Method Detail


public void handleRequest(RpcCall call,
                          RpcCallContext context,
                          ResponseChannel rspChannel)
                   throws java.lang.Exception
Description copied from interface: AsynchronousRequestHandler
Invoked to handle a method call.

This method is responsible for processing the method asynchronously. Responses can be sent using the ResponseChannel.respond(RpcResponse) method.

Although an implement could do all of its work using the calling thread the intention of this interface is to support handing off the work to an application thread.

The caller is one of the underlying worker threads (see HttpRpcProcessor.addWorker()) and as such should process the method as quickly as possible.

If an exception is raised it will be returned to the caller as an RPC fault.

Specified by:
handleRequest in interface AsynchronousRequestHandler
call - The method call to be handled.
context - An RpcCallContext instance providing information about the call context.
rspChannel - A handle to a logic channel that can be used when a response is ready.
java.lang.Exception - Implementations are permitted to raise an exception as part of their processing.


public java.lang.Class getType(java.lang.String methodName,
                               int index)
Description copied from class: MethodCallUnmarshallerAid
An implementation should return a Class instance representing the type a complex parameter value (a struct or an array) at the given index should be unmarshalled as.

A null return value will result in the parameter value being unmarshalled into a Map instance if, and only if, the parameter value is an XML-RPC struct and a List instance if, and only if, the value is an XML-RPC array.

The returned Class must be accessible, instantiable, and have an accessible default constructor.

Specified by:
getType in class MethodCallUnmarshallerAid
methodName - The name of the XML-RPC method call being unmarshalled.
index - The index of the parameter value being unmarshalled.
The Class for the type the parameter value should be unmarshalled as, assuming it is a struct or an array.


public FieldNameCodec getFieldNameCodec(java.lang.String methodName)
Description copied from class: UnmarshallerAid
Invoked when a method call unmarshaller is required.

This method allows request handlers to override the default unmarshaller implementation for a given method (or class of methods) without imposing that unmarshaller on all request handlers.

Implementations may return the same instance for multiple calls to this method as long as the unmarshaller is thread-safe.

Implementations may return null in which case a default unmarshalling implementation will be used.

getFieldNameCodec in class UnmarshallerAid
methodName - The name of the XML-RPC method call being unmarshalled.
A new MethodCallUnmarshaller instance or null.


public int sum(int[] list)
Sums an array of integers;

Specified by:
sum in interface RMIServerInterface
list - The list of integers
The sum of the input list of values.


public java.lang.String getVersionInfo(boolean verbose)
Fetch a version string.

Specified by:
getVersionInfo in interface RMIServerInterface
verbose - A flag indicating whether or not the returned version info is verbose.
A version string


public java.util.Date getDate()
Get the current date and time.

Specified by:
getDate in interface RMIServerInterface
A new Date instance set to the current date and time.


public static void main(java.lang.String[] args)
Start an instance of this demo server.

The following XML-RPC methods are supported by this server:

args - A list of parameters indicating the host/address and port to bind to. These default to localhost and 8080 if not specified.