org.apache.ws.jaxme.js.apps

Class XmlRpcClientGenerator


public class XmlRpcClientGenerator
extends java.lang.Object

This class generates clients for Apache XML-RPC. The basic idea goes as follows:
  1. Provide a class implementing the interface XmlRpcCaller.
  2. Provide a server side class being called via XML-RPC. The class must have a public default constructor, should be stateless, and all callable methods must be public instance methods.
  3. Run the generator, specifying a target package.
On the client, use the generated class, as if it were the server side class.

Constructor Summary

XmlRpcClientGenerator(JavaSourceFactory pFactory, String pTargetPackage)
Creates a new instance with the given factory and target package.

Method Summary

JavaSource
addClass(JavaSource pSource, JavaSourceResolver pResolver)
Creates a new client class, which is invoking the given server side class pSource.
protected String
addMethod(JavaMethod pMethod)
Generates a name for the method pMethod and adds it to the method map, the name being the key.
protected void
addMethods(JavaSource pResult, JavaSource pSource, Map pKeys, JavaField pField, JavaSourceResolver pResolver)
protected JavaConstructor
getConstructor(JavaSource pJs, JavaField jf)
JavaSource
getDispatcher(JavaQName pQName)
Creates the dispatcher class.
JavaConstructor
getDispatcherConstructor(JavaSource pSource, JavaField pMap, JavaQName pInvoker)
Creates the dispatchers constructor.
protected JavaMethod
getDispatcherInvokeMethod(JavaSource pSource, JavaQName pInvoker)
Creates the dispatchers invoke method.
JavaSourceFactory
getFactory()
Returns the factory, that was submitted to the constructor.
protected JavaMethod
getGetInvokerMethod(JavaSource pSource, JavaQName pInvoker, JavaField pMap)
Creates the dispatchers getInvoker method.
protected Object
getInputValue(JavaMethod pMethod, JavaQName pType, Object pValue)
Converts the given input pValue with type pType into a valid XML-RPC type.
protected JavaSource
getInvoker(JavaSource pSource, JavaMethod pMethod, JavaQName pInvoker, int pNum)
Creates a new invoker class for the given method.
JavaSource
getInvokerClass(JavaSource pSource)
Generates the abstract invoker class.
protected JavaField
getInvokerMap(JavaSource pSource)
Creates the field with the Map of invokers.
protected JavaMethod
getMethod(JavaSource pJs, JavaField pCaller, String pName, JavaMethod pMethod)
Generates a method, invoking method pMethod using the name pName.
protected Object
getResultValue(JavaMethod pMethod, JavaQName pType, Object pValue)
Converts the result value pValue into the requested type pType.
String
getTargetPackage()
Returns the target package, that was submitted to the constructor.
protected JavaField
getXmlRpcCaller(JavaSource pJs)
boolean
isDispatcherImplementsXmlRpcHandler()
Returns whether the generated dispatcher implements XmlRpcHandler.
protected boolean
isMethodGenerated(JavaMethod pMethod)
Returns, whether a remote method call is generated for method pMethod.
void
setDispatcherImplementsXmlRpcHandler(boolean pDispatcherImplementsXmlRpcHandler)
Sets whether the generated dispatcher implements XmlRpcHandler.

Constructor Details

XmlRpcClientGenerator

public XmlRpcClientGenerator(JavaSourceFactory pFactory,
                             String pTargetPackage)
Creates a new instance with the given factory and target package.

Method Details

addClass

public JavaSource addClass(JavaSource pSource,
                           JavaSourceResolver pResolver)
            throws SecurityException,
                   NoSuchMethodException
Creates a new client class, which is invoking the given server side class pSource.

addMethod

protected String addMethod(JavaMethod pMethod)
Generates a name for the method pMethod and adds it to the method map, the name being the key.
Returns:
The generated name.

addMethods

protected void addMethods(JavaSource pResult,
                          JavaSource pSource,
                          Map pKeys,
                          JavaField pField,
                          JavaSourceResolver pResolver)
            throws SecurityException,
                   NoSuchMethodException

getConstructor

protected JavaConstructor getConstructor(JavaSource pJs,
                                         JavaField jf)

getDispatcher

public JavaSource getDispatcher(JavaQName pQName)
Creates the dispatcher class. Make sure, that this method is invoked after addClass(JavaSource,JavaSourceResolver)!
Parameters:
pQName - Fully qualified class name of the dispatcher class.

getDispatcherConstructor

public JavaConstructor getDispatcherConstructor(JavaSource pSource,
                                                JavaField pMap,
                                                JavaQName pInvoker)
Creates the dispatchers constructor.

getDispatcherInvokeMethod

protected JavaMethod getDispatcherInvokeMethod(JavaSource pSource,
                                               JavaQName pInvoker)
Creates the dispatchers invoke method.

getFactory

public JavaSourceFactory getFactory()
Returns the factory, that was submitted to the constructor.

getGetInvokerMethod

protected JavaMethod getGetInvokerMethod(JavaSource pSource,
                                         JavaQName pInvoker,
                                         JavaField pMap)
Creates the dispatchers getInvoker method.

getInputValue

protected Object getInputValue(JavaMethod pMethod,
                               JavaQName pType,
                               Object pValue)
Converts the given input pValue with type pType into a valid XML-RPC type.

getInvoker

protected JavaSource getInvoker(JavaSource pSource,
                                JavaMethod pMethod,
                                JavaQName pInvoker,
                                int pNum)
Creates a new invoker class for the given method.

getInvokerClass

public JavaSource getInvokerClass(JavaSource pSource)
Generates the abstract invoker class.

getInvokerMap

protected JavaField getInvokerMap(JavaSource pSource)
Creates the field with the Map of invokers.

getMethod

protected JavaMethod getMethod(JavaSource pJs,
                               JavaField pCaller,
                               String pName,
                               JavaMethod pMethod)
            throws SecurityException,
                   NoSuchMethodException
Generates a method, invoking method pMethod using the name pName.

getResultValue

protected Object getResultValue(JavaMethod pMethod,
                                JavaQName pType,
                                Object pValue)
Converts the result value pValue into the requested type pType.

getTargetPackage

public String getTargetPackage()
Returns the target package, that was submitted to the constructor.

getXmlRpcCaller

protected JavaField getXmlRpcCaller(JavaSource pJs)

isDispatcherImplementsXmlRpcHandler

public boolean isDispatcherImplementsXmlRpcHandler()
Returns whether the generated dispatcher implements XmlRpcHandler. The default value is true.

isMethodGenerated

protected boolean isMethodGenerated(JavaMethod pMethod)
Returns, whether a remote method call is generated for method pMethod. The default implementation returns true, if the method is public and not static.

setDispatcherImplementsXmlRpcHandler

public void setDispatcherImplementsXmlRpcHandler(boolean pDispatcherImplementsXmlRpcHandler)
Sets whether the generated dispatcher implements XmlRpcHandler. The default value is true.