org.codehaus.plexus.xmlrpc
Class DefaultXmlRpcComponent

java.lang.Object
  extended byorg.codehaus.plexus.logging.AbstractLogEnabled
      extended byorg.codehaus.plexus.xmlrpc.DefaultXmlRpcComponent
All Implemented Interfaces:
org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable, XmlRpcComponent

public class DefaultXmlRpcComponent
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable, org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable, XmlRpcComponent

Version:
$Id: DefaultXmlRpcComponent.java 2752 2005-10-24 10:41:24Z evenisse $
Author:
Jason van Zyl

Field Summary
private  java.util.List acceptedClients
          Accepted Clients.
private  org.codehaus.plexus.PlexusContainer container
           
private  java.util.List deniedClients
          Denied Clients.
private  java.util.List handlers
          Handlers.
private  boolean isInitialized
           
private  boolean isSecureServer
          Secure server state.
private  java.util.List listeners
          Message Listeners.
private  boolean paranoid
          Paranoid state.
private  int port
          The port to listen on.
private  java.lang.String saxParserClass
          SAX Parser class.
private  java.util.Properties systemProperties
          A set of properties to configure SSL and JSSE
private  XmlRpcServer xmlRpcServer
          The standalone xmlrpc server.
 
Fields inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
 
Fields inherited from interface org.codehaus.plexus.xmlrpc.XmlRpcComponent
ROLE
 
Constructor Summary
DefaultXmlRpcComponent()
           
 
Method Summary
 void acceptClient(java.lang.String address)
          Add an IP address to the list of accepted clients.
 void addMessageListener(XmlRpcMessageListener listener)
          Add message listener.
 void contextualize(org.codehaus.plexus.context.Context context)
           
 void denyClient(java.lang.String address)
          Add an IP address to the list of denied clients.
 java.lang.Object executeRpc(java.net.URL url, java.lang.String methodName, java.util.Vector params)
          Client's interface to XML-RPC.
private  java.lang.String getClient(java.util.List list, int index)
           
 void initialize()
           
 void messageReceived(java.lang.String message)
          Message received.
private  void registerComponentHandler(java.lang.String handlerName, java.lang.String handlerRole)
          Helper that registers a component as a handler with the specified handler name.
 void registerHandler(java.lang.Object handler)
          Register an Object as a default handler for the service.
 void registerHandler(java.lang.String handlerName, java.lang.Object handler)
          Register an Object as a handler for the service.
private  void registerStartupHandlers()
          Registers any handlers that were defined as part this component's configuration.
 void setParanoid(boolean state)
          Switch client filtering on/off.
private  void setSystemPropertiesFromConfiguration()
          Create System properties using the key-value pairs in a given Configuration.
 void start()
           
 void stop()
           
 void unregisterHandler(java.lang.String handlerName)
          Unregister a handler.
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

private org.codehaus.plexus.PlexusContainer container

port

private int port
The port to listen on.


isSecureServer

private boolean isSecureServer
Secure server state.


saxParserClass

private java.lang.String saxParserClass
SAX Parser class.


paranoid

private boolean paranoid
Paranoid state.


handlers

private java.util.List handlers
Handlers.


acceptedClients

private java.util.List acceptedClients
Accepted Clients.


deniedClients

private java.util.List deniedClients
Denied Clients.


systemProperties

private java.util.Properties systemProperties
A set of properties to configure SSL and JSSE


listeners

private java.util.List listeners
Message Listeners.


isInitialized

private boolean isInitialized

xmlRpcServer

private XmlRpcServer xmlRpcServer
The standalone xmlrpc server.

Constructor Detail

DefaultXmlRpcComponent

public DefaultXmlRpcComponent()
Method Detail

contextualize

public void contextualize(org.codehaus.plexus.context.Context context)
                   throws org.codehaus.plexus.context.ContextException
Specified by:
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Throws:
org.codehaus.plexus.context.ContextException

initialize

public void initialize()
                throws org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
Specified by:
initialize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
Throws:
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException

start

public void start()
           throws org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException
Specified by:
start in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable
Throws:
org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException

stop

public void stop()
          throws org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException
Specified by:
stop in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable
Throws:
org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException

registerStartupHandlers

private void registerStartupHandlers()
                              throws java.lang.Exception
Registers any handlers that were defined as part this component's configuration. A handler may be defined as a class (which will be instantiated) or as a role in which case it will be looked up.

Throws:
java.lang.Exception - If there were errors registering a handler.

registerHandler

public void registerHandler(java.lang.Object handler)
                     throws org.apache.xmlrpc.XmlRpcException,
                            java.io.IOException
Register an Object as a default handler for the service.

Specified by:
registerHandler in interface XmlRpcComponent
Parameters:
handler - The handler to use.
Throws:
org.apache.xmlrpc.XmlRpcException
java.io.IOException

registerHandler

public void registerHandler(java.lang.String handlerName,
                            java.lang.Object handler)
                     throws org.apache.xmlrpc.XmlRpcException,
                            java.io.IOException
Register an Object as a handler for the service.

Specified by:
registerHandler in interface XmlRpcComponent
Parameters:
handlerName - The name the handler is registered under.
handler - The handler to use.
Throws:
org.apache.xmlrpc.XmlRpcException - If an XmlRpcException occurs.
java.io.IOException - If an IOException occurs.

registerComponentHandler

private void registerComponentHandler(java.lang.String handlerName,
                                      java.lang.String handlerRole)
                               throws java.lang.Exception
Helper that registers a component as a handler with the specified handler name.

Parameters:
handlerName - The name to register this handle as.
handlerRole - The role of the component serving as the handler.
Throws:
java.lang.Exception - If the component could not be looked up.

unregisterHandler

public void unregisterHandler(java.lang.String handlerName)
                       throws org.apache.xmlrpc.XmlRpcException
Unregister a handler.

Specified by:
unregisterHandler in interface XmlRpcComponent
Parameters:
handlerName - The name of the handler to unregister.
Throws:
org.apache.xmlrpc.XmlRpcException

executeRpc

public java.lang.Object executeRpc(java.net.URL url,
                                   java.lang.String methodName,
                                   java.util.Vector params)
                            throws java.lang.Exception
Client's interface to XML-RPC. The return type is Object which you'll need to cast to whatever you are expecting.

Specified by:
executeRpc in interface XmlRpcComponent
Parameters:
url - A URL.
methodName - A String with the method name.
params - A Vector with the parameters.
Returns:
An Object.
Throws:
org.apache.xmlrpc.XmlRpcException
java.io.IOException
java.lang.Exception

setParanoid

public void setParanoid(boolean state)
Switch client filtering on/off.

Specified by:
setParanoid in interface XmlRpcComponent
Parameters:
state - Whether to filter clients.
See Also:
acceptClient(java.lang.String), denyClient(java.lang.String)

acceptClient

public void acceptClient(java.lang.String address)
Add an IP address to the list of accepted clients. The parameter can contain '*' as wildcard character, e.g. "192.168.*.*". You must call setParanoid(true) in order for this to have any effect.

Specified by:
acceptClient in interface XmlRpcComponent
Parameters:
address - The address to add to the list.
See Also:
denyClient(java.lang.String), setParanoid(boolean)

denyClient

public void denyClient(java.lang.String address)
Add an IP address to the list of denied clients. The parameter can contain '*' as wildcard character, e.g. "192.168.*.*". You must call setParanoid(true) in order for this to have any effect.

Specified by:
denyClient in interface XmlRpcComponent
Parameters:
address - The address to add to the list.
See Also:
acceptClient(java.lang.String), setParanoid(boolean)

addMessageListener

public void addMessageListener(XmlRpcMessageListener listener)
Add message listener.

Specified by:
addMessageListener in interface XmlRpcComponent

messageReceived

public void messageReceived(java.lang.String message)
Message received.

Specified by:
messageReceived in interface XmlRpcComponent

setSystemPropertiesFromConfiguration

private void setSystemPropertiesFromConfiguration()
Create System properties using the key-value pairs in a given Configuration. This is used to set system properties and the URL https connection handler needed by JSSE to enable SSL between XMLRPC client and server.


getClient

private java.lang.String getClient(java.util.List list,
                                   int index)
                            throws org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
Throws:
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException