org.apache.xmlrpc

Class XmlRpcClient

Implemented Interfaces:
XmlRpcHandler
Known Direct Subclasses:
SecureXmlRpcClient, XmlRpcClientLite

public class XmlRpcClient
extends java.lang.Object
implements XmlRpcHandler

A multithreaded, reusable XML-RPC client object. Use this if you need a full-grown HTTP client (e.g. for Proxy and Basic Auth support). If you don't need that, XmlRpcClientLite may work better for you.
Version:
$Id: XmlRpcClient.java 350048 2005-11-30 21:49:32 +0100 (Mi, 30 Nov 2005) jochen $
Authors:
Hannes Wallnoefer
Andrew Evers
Ryan Hoegg

Nested Class Summary

(package private) class
XmlRpcClient.CallData
(package private) class
XmlRpcClient.XmlRpcClientAsyncThread

Field Summary

protected int
asyncWorkers
private XmlRpcClient.CallData
first
private XmlRpcClient.CallData
last
private int
maxThreads
The maximum number of threads which can be used concurrently, by defaut use the one defined in XmlRpc
protected Stack
pool
private String
storedPassword
private String
storedUser
protected XmlRpcTransportFactory
transportFactory
(package private) TimeZone
tz
protected URL
url
protected int
workers

Constructor Summary

XmlRpcClient(String url)
Construct a XML-RPC client for the URL represented by this String.
XmlRpcClient(String hostname, int port)
Construct a XML-RPC client for the specified hostname and port.
XmlRpcClient(URL url)
Construct a XML-RPC client with this URL.
XmlRpcClient(URL url, XmlRpcTransportFactory transportFactory)
Construct a XML-RPC client with this URL and a specified transport factory.

Method Summary

private DefaultXmlRpcTransport
createDefaultTransport()
protected XmlRpcTransport
createTransport()
(package private) XmlRpcClient.CallData
dequeue()
(package private) void
enqueue(XmlRpcClient.CallData call)
Object
execute(String method, Vector params)
Generate an XML-RPC request and send it to the server.
Object
execute(XmlRpcClientRequest request)
Object
execute(XmlRpcClientRequest request, XmlRpcTransport transport)
void
executeAsync(String method, Vector params, AsyncCallback callback)
Generate an XML-RPC request and send it to the server in a new thread.
void
executeAsync(XmlRpcClientRequest request, AsyncCallback callback)
void
executeAsync(XmlRpcClientRequest request, AsyncCallback callback, XmlRpcTransport transport)
int
getMaxThreads()
Get the MaxThreads for this Client
TimeZone
getTimeZone()
URL
getURL()
Return the URL for this XML-RPC client.
(package private) XmlRpcClientWorker
getWorker(boolean async)
static void
main(args[] )
Just for testing.
(package private) void
releaseWorker(XmlRpcClientWorker w, boolean async)
Release possibly big per-call object references to allow them to be garbage collected
void
setBasicAuthentication(String user, String password)
Deprecated. Authentication is now handled by each XmlRpcTransport
void
setMaxThreads(int maxThreads)
Set the MaxThreads for this Client
void
setTimeZone(TimeZone z)

Field Details

asyncWorkers

protected int asyncWorkers

first

private XmlRpcClient.CallData first

last

private XmlRpcClient.CallData last

maxThreads

private int maxThreads
The maximum number of threads which can be used concurrently, by defaut use the one defined in XmlRpc

pool

protected Stack pool

storedPassword

private String storedPassword

storedUser

private String storedUser

transportFactory

protected XmlRpcTransportFactory transportFactory

tz

(package private)  TimeZone tz

url

protected URL url

workers

protected int workers

Constructor Details

XmlRpcClient

public XmlRpcClient(String url)
            throws MalformedURLException
Construct a XML-RPC client for the URL represented by this String.

XmlRpcClient

public XmlRpcClient(String hostname,
                    int port)
            throws MalformedURLException
Construct a XML-RPC client for the specified hostname and port.

XmlRpcClient

public XmlRpcClient(URL url)
Construct a XML-RPC client with this URL.

XmlRpcClient

public XmlRpcClient(URL url,
                    XmlRpcTransportFactory transportFactory)
Construct a XML-RPC client with this URL and a specified transport factory.

Method Details

createDefaultTransport

private DefaultXmlRpcTransport createDefaultTransport()

createTransport

protected XmlRpcTransport createTransport()
            throws XmlRpcClientException

dequeue

(package private)  XmlRpcClient.CallData dequeue()
Returns:

enqueue

(package private)  void enqueue(XmlRpcClient.CallData call)
Parameters:

execute

public Object execute(String method,
                      Vector params)
            throws XmlRpcException,
                   IOException
Generate an XML-RPC request and send it to the server. Parse the result and return the corresponding Java object.
Specified by:
execute in interface XmlRpcHandler

execute

public Object execute(XmlRpcClientRequest request)
            throws XmlRpcException,
                   IOException

execute

public Object execute(XmlRpcClientRequest request,
                      XmlRpcTransport transport)
            throws XmlRpcException,
                   IOException

executeAsync

public void executeAsync(String method,
                         Vector params,
                         AsyncCallback callback)
Generate an XML-RPC request and send it to the server in a new thread. This method returns immediately. If the callback parameter is not null, it will be called later to handle the result or error when the call is finished.

executeAsync

public void executeAsync(XmlRpcClientRequest request,
                         AsyncCallback callback)

executeAsync

public void executeAsync(XmlRpcClientRequest request,
                         AsyncCallback callback,
                         XmlRpcTransport transport)

getMaxThreads

public int getMaxThreads()
Get the MaxThreads for this Client

getTimeZone

public TimeZone getTimeZone()

getURL

public URL getURL()
Return the URL for this XML-RPC client.

getWorker

(package private)  XmlRpcClientWorker getWorker(boolean async)
            throws IOException
Parameters:
async -
Returns:

main

public static void main(args[] )
            throws Exception
Just for testing.

releaseWorker

(package private)  void releaseWorker(XmlRpcClientWorker w,
                                      boolean async)
Release possibly big per-call object references to allow them to be garbage collected

setBasicAuthentication

public void setBasicAuthentication(String user,
                                   String password)

Deprecated. Authentication is now handled by each XmlRpcTransport

Sets Authentication for this client. This will be sent as Basic Authentication header to the server as described in http://www.ietf.org/rfc/rfc2617.txt. This method has been deprecated. Furthermore, it has no effect on the overloads for execute and executeAsync that use an XmlRpcClientRequest or an XmlRpcTransport.

setMaxThreads

public void setMaxThreads(int maxThreads)
Set the MaxThreads for this Client

setTimeZone

public void setTimeZone(TimeZone z)

Copyright B) 1999-2002 Apache Software Foundation. All Rights Reserved.