redstone.xmlrpc.handlers
Class ReflectiveInvocationHandler

java.lang.Object
  extended by redstone.xmlrpc.handlers.ReflectiveInvocationHandler
All Implemented Interfaces:
XmlRpcInvocationHandler
Direct Known Subclasses:
ValidationHandler

public class ReflectiveInvocationHandler
extends java.lang.Object
implements XmlRpcInvocationHandler

Note that methods that are to be called over XML-RPC need to be public, or the client will receive a fault message.

Author:
Greger Olsson

Constructor Summary
ReflectiveInvocationHandler()
          Constructs the handler and sets the current object as the target.
ReflectiveInvocationHandler(java.lang.Object target)
          Constructs the handler and sets the supplied object as the invocation target.
ReflectiveInvocationHandler(java.lang.Object target, java.lang.String[] entryPoints)
          Constructs the handler and sets the supplied objects as the invocation target.
 
Method Summary
 java.lang.Object invoke(java.lang.String methodName, java.util.List arguments)
          Called by the XmlRpcServer when a method is to be invoked.
 void setEntryPoints(java.lang.String[] entryPoints)
          Assigns a list of method names that are used when invoking methods on this handler.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectiveInvocationHandler

public ReflectiveInvocationHandler()
Constructs the handler and sets the current object as the target. That is, use 'this' as the target to receive the invocations.


ReflectiveInvocationHandler

public ReflectiveInvocationHandler(java.lang.Object target)
Constructs the handler and sets the supplied object as the invocation target. This is used when wrapping an object in a reflective handler. Wrapping is useful if you want to publish an object that is not a ReflectiveInvocationHander.

Parameters:
target - The object to wrap up.

ReflectiveInvocationHandler

public ReflectiveInvocationHandler(java.lang.Object target,
                                   java.lang.String[] entryPoints)
Constructs the handler and sets the supplied objects as the invocation target. This is used when wrapping an object in a reflective handler. The user may also specify a list of methods that should be available in the target.

Parameters:
target - The object to wrap up.
entryPoints - A list of method names that should be available for invocation.
Method Detail

setEntryPoints

public void setEntryPoints(java.lang.String[] entryPoints)
Assigns a list of method names that are used when invoking methods on this handler. After calling this method, only methods listed in the supplied entryPoints list will be available for invocation. Note that for a given method "testMethod", all overloaded versions of that method will be available. That is, the invocation mechanism does not take into account parameter lists, just names.

A null entry point list means all public methods are available.

Parameters:
entryPoints - A list of method names that may be invoked on this handler, or null if all methods should be available.

invoke

public java.lang.Object invoke(java.lang.String methodName,
                               java.util.List arguments)
                        throws java.lang.Throwable
Called by the XmlRpcServer when a method is to be invoked. This implementation tries to locate the supplied method in the target object using Java Reflection. If the invocation handler keeps a list of published methods, this is first checked to see if the call should be carried through.

Specified by:
invoke in interface XmlRpcInvocationHandler
Parameters:
methodName - The name of the method to call.
arguments - A vector containting all arguments required by the method.
Returns:
The return value from the method.
Throws:
java.lang.Throwable - Any kind of exception may occurr in the method.