com.flat502.rox.server
Class ProxyingRequestHandler

java.lang.Object
  extended by com.flat502.rox.marshal.UnmarshallerAid
      extended by com.flat502.rox.marshal.MethodCallUnmarshallerAid
          extended by com.flat502.rox.server.ProxyingRequestHandler
All Implemented Interfaces:
RequestHandler, SynchronousRequestHandler
Direct Known Subclasses:
XmlRpcProxyingRequestHandler

public abstract class ProxyingRequestHandler
extends MethodCallUnmarshallerAid
implements SynchronousRequestHandler

A SynchronousRequestHandler implementation that maps RPC method calls onto methods on an arbitrary object using reflection.

Sub-classes provide the concrete instance of RpcMethodProxy and the rest is handled by delegating appropriately to that instance.


Constructor Summary
ProxyingRequestHandler(RpcMethodProxy proxy)
           
 
Method Summary
 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.
 RpcResponse handleRequest(RpcCall call)
          Deprecated. Override handleRequest(RpcCall, RpcCallContext) instead.
 RpcResponse handleRequest(RpcCall call, RpcCallContext context)
          Invoked to handle a method call.
 
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

ProxyingRequestHandler

public ProxyingRequestHandler(RpcMethodProxy proxy)
Method Detail

handleRequest

public RpcResponse handleRequest(RpcCall call)
                          throws java.lang.Exception
Deprecated. Override handleRequest(RpcCall, RpcCallContext) instead.

Throws:
java.lang.Exception

handleRequest

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

This method is responsible for processing the method synchronously. The return value will be marshalled and sent back to the client immediately.

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

If processing might be length consider using AsynchronousRequestHandler and handing off the work to an application thread.

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

Specified by:
handleRequest in interface SynchronousRequestHandler
Parameters:
call - The method call to be handled.
context - An RpcCallContext instance providing information about the call context.
Returns:
An appropriate RPC response.
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:
this implementation always returns null.