marquee.xmlrpc.handlers
Class ReflectiveInvocationHandler

java.lang.Object
  extended bymarquee.xmlrpc.handlers.ReflectiveInvocationHandler
All Implemented Interfaces:
XmlRpcInvocationHandler
Direct Known Subclasses:
InvocationHandler, ServletExample.ExampleInvocationHandler, SessionExampleServer.SessionExampleHandler, Validator

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 java.lang.NoSuchMethod exception.

Since:
JDK 1.1
Version:
$Revision: 1.8 $
Author:
Greger Ohlson (greger.ohlson@marquee.se), Rainer Bischof (rainer.bischof@eds.com)

Constructor Summary
ReflectiveInvocationHandler()
          Constructs the handler and sets the current object (from the class extending this class) as the target.
ReflectiveInvocationHandler(java.lang.Object target)
          Constructs the handler and sets the supplied objects 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.Collection 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 (from the class extending this class) as the target.


ReflectiveInvocationHandler

public ReflectiveInvocationHandler(java.lang.Object target)
Constructs the handler and sets the supplied objects as the invocation target. This is used when wrapping an object in a reflective handler.

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 final 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 final java.lang.Object invoke(java.lang.String methodName,
                                     java.util.Collection 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 result.
Throws:
java.lang.Throwable - may throw any Exception