org.apache.ws.jaxme.js.apps

Class XmlRpcClientGenerator

public class XmlRpcClientGenerator extends 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
JavaSourceaddClass(JavaSource pSource, JavaSourceResolver pResolver)
Creates a new client class, which is invoking the given server side class pSource.
protected StringaddMethod(JavaMethod pMethod)
Generates a name for the method pMethod and adds it to the method map, the name being the key.
protected voidaddMethods(JavaSource pResult, JavaSource pSource, Map pKeys, JavaField pField, JavaSourceResolver pResolver)
protected JavaConstructorgetConstructor(JavaSource pJs, JavaField jf)
JavaSourcegetDispatcher(JavaQName pQName)
Creates the dispatcher class.
JavaConstructorgetDispatcherConstructor(JavaSource pSource, JavaField pMap, JavaQName pInvoker)
Creates the dispatchers constructor.
protected JavaMethodgetDispatcherInvokeMethod(JavaSource pSource, JavaQName pInvoker)
Creates the dispatchers invoke method.
JavaSourceFactorygetFactory()
Returns the factory, that was submitted to the constructor.
protected JavaMethodgetGetInvokerMethod(JavaSource pSource, JavaQName pInvoker, JavaField pMap)
Creates the dispatchers getInvoker method.
protected ObjectgetInputValue(JavaMethod pMethod, JavaQName pType, Object pValue)
Converts the given input pValue with type pType into a valid XML-RPC type.
protected JavaSourcegetInvoker(JavaSource pSource, JavaMethod pMethod, JavaQName pInvoker, int pNum)
Creates a new invoker class for the given method.
JavaSourcegetInvokerClass(JavaSource pSource)
Generates the abstract invoker class.
protected JavaFieldgetInvokerMap(JavaSource pSource)
Creates the field with the Map of invokers.
protected JavaMethodgetMethod(JavaSource pJs, JavaField pCaller, String pName, JavaMethod pMethod)
Generates a method, invoking method pMethod using the name pName.
protected ObjectgetResultValue(JavaMethod pMethod, JavaQName pType, Object pValue)
Converts the result value pValue into the requested type pType.
StringgetTargetPackage()
Returns the target package, that was submitted to the constructor.
protected JavaFieldgetXmlRpcCaller(JavaSource pJs)
booleanisDispatcherImplementsXmlRpcHandler()
Returns whether the generated dispatcher implements XmlRpcHandler.
protected booleanisMethodGenerated(JavaMethod pMethod)
Returns, whether a remote method call is generated for method pMethod.
voidsetDispatcherImplementsXmlRpcHandler(boolean pDispatcherImplementsXmlRpcHandler)
Sets whether the generated dispatcher implements XmlRpcHandler.

Constructor Detail

XmlRpcClientGenerator

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

Method Detail

addClass

public JavaSource addClass(JavaSource pSource, JavaSourceResolver pResolver)
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)

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 XmlRpcClientGenerator!

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)
Generates a method, invoking method pMethod using the name pName.

Throws: NoSuchMethodException SecurityException

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.