Class AbstractReflectiveHandlerMapping
- java.lang.Object
-
- org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping
-
- All Implemented Interfaces:
XmlRpcListableHandlerMapping
,XmlRpcHandlerMapping
- Direct Known Subclasses:
PropertyHandlerMapping
public abstract class AbstractReflectiveHandlerMapping extends java.lang.Object implements XmlRpcListableHandlerMapping
Abstract base class of handler mappings, which are using reflection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractReflectiveHandlerMapping.AuthenticationHandler
An object implementing this interface may be used to validate user names and passwords.
-
Field Summary
Fields Modifier and Type Field Description private AbstractReflectiveHandlerMapping.AuthenticationHandler
authenticationHandler
protected java.util.Map
handlerMap
private RequestProcessorFactoryFactory
requestProcessorFactoryFactory
private TypeConverterFactory
typeConverterFactory
private boolean
voidMethodEnabled
-
Constructor Summary
Constructors Constructor Description AbstractReflectiveHandlerMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractReflectiveHandlerMapping.AuthenticationHandler
getAuthenticationHandler()
Returns the authentication handler, if any, or null.XmlRpcHandler
getHandler(java.lang.String pHandlerName)
Returns theXmlRpcHandler
with the given name.java.lang.String[]
getListMethods()
This method implements the introspection methodsystem.listMethods
, which is specified as follows:protected java.lang.String
getMethodHelp(java.lang.Class pClass, java.lang.reflect.Method[] pMethods)
Creates a help string for the given method, when applied to the given class.java.lang.String
getMethodHelp(java.lang.String pHandlerName)
This method implements the introspection methodsystem.methodSignature
, which is specified as follows:java.lang.String[][]
getMethodSignature(java.lang.String pHandlerName)
This method implements the introspection methodsystem.methodSignature
, which is specified as follows:RequestProcessorFactoryFactory
getRequestProcessorFactoryFactory()
Returns the mappingsRequestProcessorFactoryFactory
.protected java.lang.String[][]
getSignature(java.lang.reflect.Method[] pMethods)
Creates a signature for the given method.TypeConverterFactory
getTypeConverterFactory()
Returns the mappingsTypeConverterFactory
.protected boolean
isHandlerMethod(java.lang.reflect.Method pMethod)
boolean
isVoidMethodEnabled()
Returns, whether void methods are enabled.protected XmlRpcHandler
newXmlRpcHandler(java.lang.Class pClass, java.lang.reflect.Method[] pMethods)
Creates a new instance ofXmlRpcHandler
.protected void
registerPublicMethods(java.lang.String pKey, java.lang.Class pType)
Searches for methods in the given class.void
setAuthenticationHandler(AbstractReflectiveHandlerMapping.AuthenticationHandler pAuthenticationHandler)
Sets the authentication handler, if any, or null.void
setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory)
Sets the mappingsRequestProcessorFactoryFactory
.void
setTypeConverterFactory(TypeConverterFactory pFactory)
Sets the mappingsTypeConverterFactory
.void
setVoidMethodEnabled(boolean pVoidMethodEnabled)
Sets, whether void methods are enabled.
-
-
-
Field Detail
-
typeConverterFactory
private TypeConverterFactory typeConverterFactory
-
handlerMap
protected java.util.Map handlerMap
-
authenticationHandler
private AbstractReflectiveHandlerMapping.AuthenticationHandler authenticationHandler
-
requestProcessorFactoryFactory
private RequestProcessorFactoryFactory requestProcessorFactoryFactory
-
voidMethodEnabled
private boolean voidMethodEnabled
-
-
Method Detail
-
setTypeConverterFactory
public void setTypeConverterFactory(TypeConverterFactory pFactory)
Sets the mappingsTypeConverterFactory
.
-
getTypeConverterFactory
public TypeConverterFactory getTypeConverterFactory()
Returns the mappingsTypeConverterFactory
.
-
setRequestProcessorFactoryFactory
public void setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory)
Sets the mappingsRequestProcessorFactoryFactory
. Note, that this doesn't affect already registered handlers.
-
getRequestProcessorFactoryFactory
public RequestProcessorFactoryFactory getRequestProcessorFactoryFactory()
Returns the mappingsRequestProcessorFactoryFactory
.
-
getAuthenticationHandler
public AbstractReflectiveHandlerMapping.AuthenticationHandler getAuthenticationHandler()
Returns the authentication handler, if any, or null.
-
setAuthenticationHandler
public void setAuthenticationHandler(AbstractReflectiveHandlerMapping.AuthenticationHandler pAuthenticationHandler)
Sets the authentication handler, if any, or null.
-
isHandlerMethod
protected boolean isHandlerMethod(java.lang.reflect.Method pMethod)
-
registerPublicMethods
protected void registerPublicMethods(java.lang.String pKey, java.lang.Class pType) throws XmlRpcException
Searches for methods in the given class. For any valid method, it creates an instance ofXmlRpcHandler
. Valid methods are defined as follows:- They must be public.
- They must not be static.
- The return type must not be void.
- The declaring class must not be
Object
. - If multiple methods with the same name exist, which meet the above conditins, then an attempt is made to identify a method with a matching signature. If such a method is found, then this method is invoked. If multiple such methods are found, then the first one is choosen. (This may be the case, for example, if there are methods with a similar signature, but varying subclasses.) Note, that there is no concept of the "most matching" method. If no matching method is found at all, then an exception is thrown.
- Parameters:
pKey
- Suffix for building handler names. A dot and the method name are being added.pType
- The class being inspected.- Throws:
XmlRpcException
-
newXmlRpcHandler
protected XmlRpcHandler newXmlRpcHandler(java.lang.Class pClass, java.lang.reflect.Method[] pMethods) throws XmlRpcException
Creates a new instance ofXmlRpcHandler
.- Parameters:
pClass
- The class, which was inspected for handler methods. This is used for error messages only. Typically, it is the same thanpInstance.getClass()
.pMethods
- The method being invoked.- Throws:
XmlRpcException
-
getSignature
protected java.lang.String[][] getSignature(java.lang.reflect.Method[] pMethods)
Creates a signature for the given method.
-
getMethodHelp
protected java.lang.String getMethodHelp(java.lang.Class pClass, java.lang.reflect.Method[] pMethods)
Creates a help string for the given method, when applied to the given class.
-
getHandler
public XmlRpcHandler getHandler(java.lang.String pHandlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException
Returns theXmlRpcHandler
with the given name.- Specified by:
getHandler
in interfaceXmlRpcHandlerMapping
- Parameters:
pHandlerName
- The handlers name- Returns:
- Object The desired handler. Never null, an exception is thrown if no such handler is available.
- Throws:
XmlRpcNoSuchHandlerException
- A handler with the given name is unknown.XmlRpcException
- An internal error occurred.
-
getListMethods
public java.lang.String[] getListMethods() throws XmlRpcException
Description copied from interface:XmlRpcListableHandlerMapping
This method implements the introspection methodsystem.listMethods
, which is specified as follows:This method may be used to enumerate the methods implemented by the XML-RPC server.
The
system.listMethods
method requires no parameters. It returns an array of strings, each of which is the name of a method implemented by the server.Note, that the specification doesn't require that the list must be exhaustive. We conclude, that a valid method "handlerName" doesn't need to be in the list. For example, a handler, which implements
XmlRpcHandler
, but notXmlRpcMetaDataHandler
, should possibly excluded: Otherwise, the listable handler mapping could not provide meaningful replies tosystem.methodSignature
, andsystem.methodHelp
.- Specified by:
getListMethods
in interfaceXmlRpcListableHandlerMapping
- Throws:
XmlRpcException
- An internal error occurred.
-
getMethodHelp
public java.lang.String getMethodHelp(java.lang.String pHandlerName) throws XmlRpcException
Description copied from interface:XmlRpcListableHandlerMapping
This method implements the introspection methodsystem.methodSignature
, which is specified as follows:This method takes one parameter, the name of a method implemented by the XML-RPC server. It returns a documentation string describing the use of that method. If no such string is available, an empty string is returned.
The documentation string may contain HTML markup.
- Specified by:
getMethodHelp
in interfaceXmlRpcListableHandlerMapping
- Throws:
XmlRpcException
-
getMethodSignature
public java.lang.String[][] getMethodSignature(java.lang.String pHandlerName) throws XmlRpcException
Description copied from interface:XmlRpcListableHandlerMapping
This method implements the introspection methodsystem.methodSignature
, which is specified as follows:This method takes one parameter, the name of a method implemented by the XML-RPC server. It returns an array of possible signatures for this method. A signature is an array of types. The first of these types is the return type of the method, the rest are parameters.
Multiple signatures (ie. overloading) are permitted: this is the reason that an array of signatures are returned by this method.
Signatures themselves are restricted to the top level parameters expected by a method. For instance if a method expects one array of structs as a parameter, and it returns a string, its signature is simply "string, array". If it expects three integers, its signature is "string, int, int, int".
If no signature is defined for the method, a none-array value is returned. Therefore this is the way to test for a non-signature, if $resp below is the response object from a method call to system.methodSignature:
$v=$resp->value(); if ($v->kindOf()!="array") { // then the method did not have a signature defined }
See the introspect.php demo included in this distribution for an example of using this method.- Specified by:
getMethodSignature
in interfaceXmlRpcListableHandlerMapping
- Throws:
XmlRpcException
- See Also:
XmlRpcMetaDataHandler.getSignatures()
-
isVoidMethodEnabled
public boolean isVoidMethodEnabled()
Returns, whether void methods are enabled. By default, null values aren't supported by XML-RPC and void methods are in fact returning null (at least from the perspective of reflection).
-
setVoidMethodEnabled
public void setVoidMethodEnabled(boolean pVoidMethodEnabled)
Sets, whether void methods are enabled. By default, null values aren't supported by XML-RPC and void methods are in fact returning null (at least from the perspective of reflection).
-
-