org.apache.ws.jaxme.js.apps
Class XmlRpcClientGenerator

java.lang.Object
  extended by org.apache.ws.jaxme.js.apps.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, java.lang.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  java.lang.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, java.util.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  java.lang.Object getInputValue(JavaMethod pMethod, JavaQName pType, java.lang.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, java.lang.String pName, JavaMethod pMethod)
          Generates a method, invoking method pMethod using the name pName.
protected  java.lang.Object getResultValue(JavaMethod pMethod, JavaQName pType, java.lang.Object pValue)
          Converts the result value pValue into the requested type pType.
 java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcClientGenerator

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

Method Detail

isDispatcherImplementsXmlRpcHandler

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


setDispatcherImplementsXmlRpcHandler

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


getFactory

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


getTargetPackage

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


addMethod

protected java.lang.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.

getResultValue

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


getInputValue

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


getMethod

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

Throws:
java.lang.NoSuchMethodException
java.lang.SecurityException

getXmlRpcCaller

protected JavaField getXmlRpcCaller(JavaSource pJs)

getConstructor

protected JavaConstructor getConstructor(JavaSource pJs,
                                         JavaField jf)

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.


addClass

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

Throws:
java.lang.SecurityException
java.lang.NoSuchMethodException

addMethods

protected void addMethods(JavaSource pResult,
                          JavaSource pSource,
                          java.util.Map pKeys,
                          JavaField pField,
                          JavaSourceResolver pResolver)
                   throws java.lang.SecurityException,
                          java.lang.NoSuchMethodException
Throws:
java.lang.SecurityException
java.lang.NoSuchMethodException

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.


getInvoker

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


getDispatcherConstructor

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


getGetInvokerMethod

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


getDispatcherInvokeMethod

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


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.