org.apache.xmlrpc
Class XmlRpcWorker

java.lang.Object
  |
  +--org.apache.xmlrpc.XmlRpcWorker

public class XmlRpcWorker
extends java.lang.Object

Tie together the XmlRequestProcessor and XmlResponseProcessor to handle a request serially in a single thread.

Since:
1.2
Author:
Hannes Wallnoefer, Daniel Rall, Andrew Evers
See Also:
XmlRpcServer

Field Summary
protected  XmlRpcHandlerMapping handlerMapping
           
protected  XmlRpcRequestProcessor requestProcessor
           
protected  XmlRpcResponseProcessor responseProcessor
           
 
Constructor Summary
XmlRpcWorker(XmlRpcHandlerMapping handlerMapping)
          Create a new instance that will use the specified mapping.
 
Method Summary
protected  XmlRpcContext defaultContext(java.lang.String user, java.lang.String password)
          Factory method to return a default context object for the execute() method.
 byte[] execute(java.io.InputStream is, java.lang.String user, java.lang.String password)
          Decode, process and encode the response or exception for an XML-RPC request.
 byte[] execute(java.io.InputStream is, XmlRpcContext context)
          Decode, process and encode the response or exception for an XML-RPC request.
protected static java.lang.Object invokeHandler(java.lang.Object handler, XmlRpcRequest request, XmlRpcContext context)
          Pass the specified request to the handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestProcessor

protected XmlRpcRequestProcessor requestProcessor

responseProcessor

protected XmlRpcResponseProcessor responseProcessor

handlerMapping

protected XmlRpcHandlerMapping handlerMapping
Constructor Detail

XmlRpcWorker

public XmlRpcWorker(XmlRpcHandlerMapping handlerMapping)
Create a new instance that will use the specified mapping.
Method Detail

invokeHandler

protected static java.lang.Object invokeHandler(java.lang.Object handler,
                                                XmlRpcRequest request,
                                                XmlRpcContext context)
                                         throws java.lang.Exception
Pass the specified request to the handler. The handler should be an instance of XmlRpcHandler or AuthenticatedXmlRpcHandler.
Parameters:
handler - the handler to call.
request - the request information to use.
context - the context information to use.
Returns:
Object the result of calling the handler.
Throws:
ClassCastException - if the handler is not of an appropriate type.
NullPointerException - if the handler is null.
java.lang.Exception - if the handler throws an exception.

execute

public byte[] execute(java.io.InputStream is,
                      java.lang.String user,
                      java.lang.String password)
Decode, process and encode the response or exception for an XML-RPC request. This method executes the handler method with the default context.

execute

public byte[] execute(java.io.InputStream is,
                      XmlRpcContext context)
Decode, process and encode the response or exception for an XML-RPC request. This method executes will pass the specified context to the handler if the handler supports context.
Parameters:
is - the InputStream to read the request from.
context - the context for the request (may be null).
Returns:
byte[] the response.
Throws:
ParseFailed - if the request could not be parsed.
AuthenticationFailed - if the handler for the specific method required authentication and insufficient credentials were supplied.

defaultContext

protected XmlRpcContext defaultContext(java.lang.String user,
                                       java.lang.String password)
Factory method to return a default context object for the execute() method. This method can be overridden to return a custom sub-class of XmlRpcContext.
Parameters:
user - the username of the user making the request.
password - the password of the user making the request.
Returns:
XmlRpcContext the context for the reqeust.


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.