marquee.xmlrpc
Class XmlRpcProxy

java.lang.Object
  extended bymarquee.xmlrpc.XmlRpcProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
Proxy

public class XmlRpcProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

An XmlRpcProxy lets you use the services of an XML-RPC server through regular Java interfaces. It uses the Dynamic Proxy API introduced in JDK 1.3 to dynamically convert calls through Java interfaces to XML-RPC messages. This may be an improvement over the XmlRpcClient -- using a server through Java interfaces allows compilation-time type checking, IDE code completion, and prevents typos and other errors.

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

Method Summary
static java.lang.Object createProxy(java.lang.String host, int port, java.lang.String path, java.lang.Class[] interfaces)
          Creates a new dynamic proxy object that implements all supplied interfaces.
static java.lang.Object createProxy(java.lang.String host, int port, java.lang.String path, java.lang.String objectName, java.lang.Class[] interfaces)
          Creates a new dynamic proxy object that implements all supplied interfaces.
static java.lang.Object createProxy(java.net.URL url, java.lang.Class[] interfaces)
          Creates a new dynamic proxy object that implements all supplied interfaces.
static java.lang.Object createProxy(java.net.URL url, java.lang.String objectName, java.lang.Class[] interfaces)
          Creates a new dynamic proxy object that implements all supplied interfaces.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Handles method calles invoked on the proxy object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createProxy

public static java.lang.Object createProxy(java.lang.String host,
                                           int port,
                                           java.lang.String path,
                                           java.lang.Class[] interfaces)
                                    throws XmlRpcException
Creates a new dynamic proxy object that implements all supplied interfaces. This object may be type cast to any of the interface supplied in the call. Method calls through the interfaces will be translated to XML-RPC calls to the server at the supplied host, port and path.

Parameters:
host - The host of the XML-RPC server that will receive calls through the interfaces
port - The port of the XML-RPC server that will receive calls through the interfaces
path - The path of the XML-RPC server that will receive calls through the interfaces
interfaces - The list of interfaces the proxy should implement
Returns:
An object implementing the supplied interfaces with XML-RPC support
Throws:
XmlRpcException

createProxy

public static java.lang.Object createProxy(java.lang.String host,
                                           int port,
                                           java.lang.String path,
                                           java.lang.String objectName,
                                           java.lang.Class[] interfaces)
                                    throws XmlRpcException
Creates a new dynamic proxy object that implements all supplied interfaces. This object may be type cast to any of the interface supplied in the call. Method calls through the interfaces will be translated to XML-RPC calls to the server at the supplied host, port and path.

Parameters:
host - The host of the XML-RPC server that will receive calls through the interfaces
port - The port of the XML-RPC server that will receive calls through the interfaces
path - The path of the XML-RPC server that will receive calls through the interfaces
objectName - The name under which the handler is reachable
interfaces - The list of interfaces the proxy should implement
Returns:
An object implementing the supplied interfaces with XML-RPC support
Throws:
XmlRpcException

createProxy

public static java.lang.Object createProxy(java.net.URL url,
                                           java.lang.Class[] interfaces)
                                    throws XmlRpcException
Creates a new dynamic proxy object that implements all supplied interfaces. This object may be type cast to any of the interface supplied in the call. Method calls through the interfaces will be translated to XML-RPC calls to the server in the supplied url.

Parameters:
url - The XML-RPC server that will receive calls through the interfaces
interfaces - The list of interfaces the proxy should implement
Returns:
An object implementing the supplied interfaces with XML-RPC support
Throws:
XmlRpcException

createProxy

public static java.lang.Object createProxy(java.net.URL url,
                                           java.lang.String objectName,
                                           java.lang.Class[] interfaces)
                                    throws XmlRpcException
Creates a new dynamic proxy object that implements all supplied interfaces. This object may be type cast to any of the interface supplied in the call. Method calls through the interfaces will be translated to XML-RPC calls to the server in the supplied url.

Parameters:
url - The XML-RPC server that will receive calls through the interfaces
interfaces - The list of interfaces the proxy should implement
objectName - The name under which the handler is reachable
Returns:
An object implementing the supplied interfaces with XML-RPC support
Throws:
XmlRpcException

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Handles method calles invoked on the proxy object. This is not used by the application but has to be public so that the dynamic proxy has access to it. Just hand call over to the performCall method

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Returns:
Any of the values returned by an XmlRpcClient
Throws:
java.lang.Throwable