Class XmlRpcClient
- java.lang.Object
-
- org.apache.xmlrpc.common.XmlRpcController
-
- org.apache.xmlrpc.client.XmlRpcClient
-
public class XmlRpcClient extends XmlRpcController
The main access point of an XML-RPC client. This object serves mainly as an object factory. It is designed with singletons in mind: Basically, an application should be able to hold a single instance of
XmlRpcClient
in a static variable, unless you would be working with different factories.Until Apache XML-RPC 2.0, this object was used both as an object factory and as a place, where configuration details (server URL, suggested encoding, user credentials and the like) have been stored. In Apache XML-RPC 3.0, the configuration details has been moved to the
XmlRpcClientConfig
object. The configuration object is designed for being passed through the actual worker methods.A configured XmlRpcClient object is thread safe: In other words, the suggested use is, that you configure the client using
setTransportFactory(XmlRpcTransportFactory)
and similar methods, store it in a field and never modify it again. Without modifications, the client may be used for an arbitrary number of concurrent requests.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description private XmlRpcClientConfig
config
private XmlRpcTransportFactory
transportFactory
private XmlWriterFactory
xmlWriterFactory
-
Constructor Summary
Constructors Constructor Description XmlRpcClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
execute(java.lang.String pMethodName, java.lang.Object[] pParams)
Performs a request with the clients default configuration.java.lang.Object
execute(java.lang.String pMethodName, java.util.List pParams)
Performs a request with the clients default configuration.java.lang.Object
execute(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.lang.Object[] pParams)
Performs a request with the given configuration.java.lang.Object
execute(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.util.List pParams)
Performs a request with the given configuration.java.lang.Object
execute(XmlRpcRequest pRequest)
Performs a request with the clients default configuration.void
executeAsync(java.lang.String pMethodName, java.lang.Object[] pParams, AsyncCallback pCallback)
Performs an asynchronous request with the clients default configuration.void
executeAsync(java.lang.String pMethodName, java.util.List pParams, AsyncCallback pCallback)
Performs an asynchronous request with the clients default configuration.void
executeAsync(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.lang.Object[] pParams, AsyncCallback pCallback)
Performs an asynchronous request with the given configuration.void
executeAsync(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.util.List pParams, AsyncCallback pCallback)
Performs an asynchronous request with the given configuration.void
executeAsync(XmlRpcRequest pRequest, AsyncCallback pCallback)
Performs a request with the clients default configuration.XmlRpcClientConfig
getClientConfig()
Returns the clients default configuration.XmlRpcConfig
getConfig()
Returns the clients default configuration.protected XmlRpcWorkerFactory
getDefaultXmlRpcWorkerFactory()
Creates the controllers default worker factory.XmlRpcTransportFactory
getTransportFactory()
Returns the clients transport factory.XmlWriterFactory
getXmlWriterFactory()
Returns the clients instance ofXmlWriterFactory
.void
setConfig(XmlRpcClientConfig pConfig)
Sets the clients default configuration.void
setTransportFactory(XmlRpcTransportFactory pFactory)
Sets the clients transport factory.void
setXmlWriterFactory(XmlWriterFactory pFactory)
Sets the clients instance ofXmlWriterFactory
.-
Methods inherited from class org.apache.xmlrpc.common.XmlRpcController
getMaxThreads, getTypeFactory, getWorkerFactory, setMaxThreads, setTypeFactory, setWorkerFactory
-
-
-
-
Field Detail
-
transportFactory
private XmlRpcTransportFactory transportFactory
-
config
private XmlRpcClientConfig config
-
xmlWriterFactory
private XmlWriterFactory xmlWriterFactory
-
-
Method Detail
-
getDefaultXmlRpcWorkerFactory
protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory()
Description copied from class:XmlRpcController
Creates the controllers default worker factory.- Specified by:
getDefaultXmlRpcWorkerFactory
in classXmlRpcController
- Returns:
- The default factory for workers.
-
setConfig
public void setConfig(XmlRpcClientConfig pConfig)
Sets the clients default configuration. This configuration is used by the methodsexecute(String, List)
,execute(String, Object[])
, andexecute(XmlRpcRequest)
. You may overwrite this per request by usingexecute(XmlRpcClientConfig, String, List)
, orexecute(XmlRpcClientConfig, String, Object[])
.- Parameters:
pConfig
- The default request configuration.
-
getConfig
public XmlRpcConfig getConfig()
Returns the clients default configuration. This configuration is used by the methodsexecute(String, List)
,execute(String, Object[])
. You may overwrite this per request by usingexecute(XmlRpcClientConfig, String, List)
, orexecute(XmlRpcClientConfig, String, Object[])
.- Specified by:
getConfig
in classXmlRpcController
- Returns:
- The default request configuration.
-
getClientConfig
public XmlRpcClientConfig getClientConfig()
Returns the clients default configuration. Shortcut for(XmlRpcClientConfig) getConfig()
. This configuration is used by the methodsexecute(String, List)
,execute(String, Object[])
. You may overwrite this per request by usingexecute(XmlRpcClientConfig, String, List)
, orexecute(XmlRpcClientConfig, String, Object[])
- Returns:
- The default request configuration.
-
setTransportFactory
public void setTransportFactory(XmlRpcTransportFactory pFactory)
Sets the clients transport factory. The client will invoke the factory methodXmlRpcTransportFactory.getTransport()
for any request.- Parameters:
pFactory
- The clients transport factory.
-
getTransportFactory
public XmlRpcTransportFactory getTransportFactory()
Returns the clients transport factory. The client will use this factory for invocation ofXmlRpcTransportFactory.getTransport()
for any request.- Returns:
- The clients transport factory.
-
execute
public java.lang.Object execute(java.lang.String pMethodName, java.lang.Object[] pParams) throws XmlRpcException
Performs a request with the clients default configuration.- Parameters:
pMethodName
- The method being performed.pParams
- The parameters.- Returns:
- The result object.
- Throws:
XmlRpcException
- Performing the request failed.
-
execute
public java.lang.Object execute(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.lang.Object[] pParams) throws XmlRpcException
Performs a request with the given configuration.- Parameters:
pConfig
- The request configuration.pMethodName
- The method being performed.pParams
- The parameters.- Returns:
- The result object.
- Throws:
XmlRpcException
- Performing the request failed.
-
execute
public java.lang.Object execute(java.lang.String pMethodName, java.util.List pParams) throws XmlRpcException
Performs a request with the clients default configuration.- Parameters:
pMethodName
- The method being performed.pParams
- The parameters.- Returns:
- The result object.
- Throws:
XmlRpcException
- Performing the request failed.
-
execute
public java.lang.Object execute(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.util.List pParams) throws XmlRpcException
Performs a request with the given configuration.- Parameters:
pConfig
- The request configuration.pMethodName
- The method being performed.pParams
- The parameters.- Returns:
- The result object.
- Throws:
XmlRpcException
- Performing the request failed.
-
execute
public java.lang.Object execute(XmlRpcRequest pRequest) throws XmlRpcException
Performs a request with the clients default configuration.- Parameters:
pRequest
- The request being performed.- Returns:
- The result object.
- Throws:
XmlRpcException
- Performing the request failed.
-
executeAsync
public void executeAsync(java.lang.String pMethodName, java.lang.Object[] pParams, AsyncCallback pCallback) throws XmlRpcException
Performs an asynchronous request with the clients default configuration.- Parameters:
pMethodName
- The method being performed.pParams
- The parameters.pCallback
- The callback being notified when the request is finished.- Throws:
XmlRpcException
- Performing the request failed.
-
executeAsync
public void executeAsync(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.lang.Object[] pParams, AsyncCallback pCallback) throws XmlRpcException
Performs an asynchronous request with the given configuration.- Parameters:
pConfig
- The request configuration.pMethodName
- The method being performed.pParams
- The parameters.pCallback
- The callback being notified when the request is finished.- Throws:
XmlRpcException
- Performing the request failed.
-
executeAsync
public void executeAsync(java.lang.String pMethodName, java.util.List pParams, AsyncCallback pCallback) throws XmlRpcException
Performs an asynchronous request with the clients default configuration.- Parameters:
pMethodName
- The method being performed.pParams
- The parameters.pCallback
- The callback being notified when the request is finished.- Throws:
XmlRpcException
- Performing the request failed.
-
executeAsync
public void executeAsync(XmlRpcClientConfig pConfig, java.lang.String pMethodName, java.util.List pParams, AsyncCallback pCallback) throws XmlRpcException
Performs an asynchronous request with the given configuration.- Parameters:
pConfig
- The request configuration.pMethodName
- The method being performed.pParams
- The parameters.pCallback
- The callback being notified when the request is finished.- Throws:
XmlRpcException
- Performing the request failed.
-
executeAsync
public void executeAsync(XmlRpcRequest pRequest, AsyncCallback pCallback) throws XmlRpcException
Performs a request with the clients default configuration.- Parameters:
pRequest
- The request being performed.pCallback
- The callback being notified when the request is finished.- Throws:
XmlRpcException
- Performing the request failed.
-
getXmlWriterFactory
public XmlWriterFactory getXmlWriterFactory()
Returns the clients instance ofXmlWriterFactory
.- Returns:
- A factory for creating instances of
XMLWriter
.
-
setXmlWriterFactory
public void setXmlWriterFactory(XmlWriterFactory pFactory)
Sets the clients instance ofXmlWriterFactory
.- Parameters:
pFactory
- A factory for creating instances ofXMLWriter
.
-
-