redstone.xmlrpc
Class XmlRpcServer

java.lang.Object
  extended by redstone.xmlrpc.XmlRpcServer

public class XmlRpcServer
extends java.lang.Object

An XmlRpcServer is responsible for hosting a set of invocation handlers and a set of invocation interceptors. It is invoked by calling the execute() method, supplying a stream containing the XML-RPC message to be handled. The messages will be parsed and dispatched to the corresponding invocation handler, if any.

The XmlRpcServer may also be started as a service accepting connections on a given port. This way, a servlet environment is not required to be able to expose XML-RPC services. The server acts as a minimal HTTP server accepting text/xml posts containing XML-RPC messages, only.

For further information on setting up an XML-RPC server, see the documentation.

Author:
Greger Olsson

Constructor Summary
XmlRpcServer()
          Default constructor using default serializer supporting the basic types as well the custom serializers.
XmlRpcServer(XmlRpcSerializer serializer)
          Accepts a serializer to be used during serialization.
 
Method Summary
 void addInvocationHandler(java.lang.String name, java.lang.Object handler)
          Binds an invocation handler object to the given name.
 void addInvocationHandler(java.lang.String name, XmlRpcInvocationHandler handler)
          Binds an invocation handler object to the given name.
 void addInvocationInterceptor(XmlRpcInvocationInterceptor interceptor)
          Invocation interceptors are invoked on every call, regardless of which handler or method the call is intended for.
 void execute(java.io.InputStream xmlInput, java.io.Writer output)
          Dispatches the call contained in the supplied input stream.
 XmlRpcInvocationHandler getInvocationHandler(java.lang.String name)
          Returns the invocation handler with the given name.
 java.util.List<XmlRpcInvocationInterceptor> getInvocationInterceptors()
          Returns the incovation interceptors installed in this server.
 XmlRpcSerializer getSerializer()
          Returns the serializer this server is using to encode responses.
 void removeInvocationHandler(java.lang.String name)
          Unbinds a previously bound invocation handler.
 void removeInvocationInterceptor(XmlRpcInvocationInterceptor interceptor)
          Removes a previously registered invocation interceptor.
 void setSerializer(XmlRpcSerializer serializer)
          Sets the serializer this server is to use when encoding responses.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcServer

public XmlRpcServer()
Default constructor using default serializer supporting the basic types as well the custom serializers.


XmlRpcServer

public XmlRpcServer(XmlRpcSerializer serializer)
Accepts a serializer to be used during serialization.

Parameters:
serializer - The serializer to use for response messages.
Method Detail

execute

public void execute(java.io.InputStream xmlInput,
                    java.io.Writer output)
             throws XmlRpcException
Dispatches the call contained in the supplied input stream. The stream should contain a proper XML message conforming to the XML-RPC specification.

Parameters:
xmlInput - The stream containing the XML-RPC message.
xmlOutput - The stream to put the response in.
Throws:
XmlRpcException - if the input stream contains unparseable XML or if some error occurs in the SAX driver.

addInvocationHandler

public void addInvocationHandler(java.lang.String name,
                                 java.lang.Object handler)
Binds an invocation handler object to the given name.

Parameters:
name - The name to bind the handler to.
handler - The invocation handler object.

addInvocationHandler

public void addInvocationHandler(java.lang.String name,
                                 XmlRpcInvocationHandler handler)
Binds an invocation handler object to the given name.

Parameters:
name - The name to bind the handler to.
handler - The invocation handler object.

getInvocationHandler

public XmlRpcInvocationHandler getInvocationHandler(java.lang.String name)
Returns the invocation handler with the given name.

Parameters:
name - The name of the invocation handler to return.
Returns:
The invocation handler with the given name.

removeInvocationHandler

public void removeInvocationHandler(java.lang.String name)
Unbinds a previously bound invocation handler.

Parameters:
name - The name of the handler to unbind.

addInvocationInterceptor

public void addInvocationInterceptor(XmlRpcInvocationInterceptor interceptor)
Invocation interceptors are invoked on every call, regardless of which handler or method the call is intended for. Interceptors are useful for supplying entry points for logging and other utilities like transaction handling. For instance, a fictive TransactionalInvocationInterceptor may examine the name of the method called upon, and if it starts with "tx_" it may attach an additional transaction object in the argument vector.

Parameters:
interceptor - An invocation interceptor that will be invoked on every call sent to this server.

getInvocationInterceptors

public java.util.List<XmlRpcInvocationInterceptor> getInvocationInterceptors()
Returns the incovation interceptors installed in this server.

Returns:
The incovation interceptors installed in this server.

removeInvocationInterceptor

public void removeInvocationInterceptor(XmlRpcInvocationInterceptor interceptor)
Removes a previously registered invocation interceptor. The interceptor will no longer be invoked on inbound calls.

Parameters:
interceptor - The invocation interceptor to remove

getSerializer

public XmlRpcSerializer getSerializer()
Returns the serializer this server is using to encode responses.

Returns:
The serializer this server is using.

setSerializer

public void setSerializer(XmlRpcSerializer serializer)
Sets the serializer this server is to use when encoding responses.