com.flat502.rox.demo
Class RMIAsyncServerDemo

java.lang.Object
  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
RMIAsyncServerDemo()
           
 
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
ignoreMissingFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RMIAsyncServerDemo

public RMIAsyncServerDemo()
Method Detail

handleRequest

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
Parameters:
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.
Throws:
java.lang.Exception - Implementations are permitted to raise an exception as part of their processing.

getType

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
Parameters:
methodName - The name of the XML-RPC method call being unmarshalled.
index - The index of the parameter value being unmarshalled.
Returns:
The Class for the type the parameter value should be unmarshalled as, assuming it is a struct or an array.

getFieldNameCodec

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.

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

sum

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

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

getVersionInfo

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

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

getDate

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

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

main

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:

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