org.apache.turbine.services.xmlrpc
Class TurbineXmlRpcService

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitable
        |
        +--org.apache.turbine.services.BaseService
              |
              +--org.apache.turbine.services.TurbineBaseService
                    |
                    +--org.apache.turbine.services.xmlrpc.TurbineXmlRpcService
All Implemented Interfaces:
Initable, Service, XmlRpcService

public class TurbineXmlRpcService
extends TurbineBaseService
implements XmlRpcService

This is a service which will make an xml-rpc call to a remote server. Here's an example of how it would be done:

 XmlRpcService xs =
   (XmlRpcService)TurbineServices.getInstance()
   .getService(XmlRpcService.XMLRPC_SERVICE_NAME);
 Vector vec = new Vector();
 vec.addElement(new Integer(5));
 URL url = new URL("http://betty.userland.com/RPC2");
 String name = (String)xs.executeRpc(url, "examples.getStateName", vec);
 

Version:
$Id: TurbineXmlRpcService.java,v 1.6 2002/08/14 17:08:00 henning Exp $
Author:
Josh Lucas, Magnús Þór Torfason, Rafal Krzewski, Jason van Zyl, Daniel Rall

Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.xmlrpc.XmlRpcService
SERVICE_NAME
 
Constructor Summary
TurbineXmlRpcService()
           
 
Method Summary
 void acceptClient(java.lang.String address)
          Add an IP address to the list of accepted clients.
 void denyClient(java.lang.String address)
          Add an IP address to the list of denied clients.
 java.lang.Object executeAuthenticatedRpc(java.net.URL url, java.lang.String username, java.lang.String password, java.lang.String methodName, java.util.Vector params)
          Client's Authenticated interface to XML-RPC.
 java.lang.Object executeRpc(java.net.URL url, java.lang.String methodName, java.util.Vector params)
          Client's interface to XML-RPC.
 void get(java.lang.String serverURL, java.lang.String sourceLocationProperty, java.lang.String sourceFileName, java.lang.String destinationLocationProperty, java.lang.String destinationFileName)
          Method to allow a client to get a file to a server.
 void get(java.lang.String serverURL, java.lang.String username, java.lang.String password, java.lang.String sourceLocationProperty, java.lang.String sourceFileName, java.lang.String destinationLocationProperty, java.lang.String destinationFileName)
          Method to allow a client to get a file from a server that requires authentication.
 byte[] handleRequest(java.io.InputStream is)
          Handle an XML-RPC request using the encapsulated server.
 byte[] handleRequest(java.io.InputStream is, java.lang.String user, java.lang.String password)
          Handle an XML-RPC request using the encapsulated server with user authentication.
 void init(javax.servlet.ServletConfig config)
          This function initializes the XmlRpcService.
 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.
 void registerHandler(java.lang.String handlerName, java.lang.String handlerClass)
          A helper method that tries to initialize a handler and register it.
 void remove(java.lang.String serverURL, java.lang.String sourceLocationProperty, java.lang.String sourceFileName)
          Method to allow a client to remove a file from the server
 void remove(java.lang.String serverURL, java.lang.String username, java.lang.String password, java.lang.String sourceLocationProperty, java.lang.String sourceFileName)
          Method to allow a client to remove a file from a server that requires authentication.
 void send(java.lang.String serverURL, java.lang.String sourceLocationProperty, java.lang.String sourceFileName, java.lang.String destinationLocationProperty, java.lang.String destinationFileName)
          Method to allow a client to send a file to a server.
 void send(java.lang.String serverURL, java.lang.String username, java.lang.String password, java.lang.String sourceLocationProperty, java.lang.String sourceFileName, java.lang.String destinationLocationProperty, java.lang.String destinationFileName)
          Method to allow a client to send a file to a server that requires authentication
 void setParanoid(boolean state)
          Switch client filtering on/off.
 void shutdown()
          Shuts down this service, stopping running threads.
 void unregisterHandler(java.lang.String handlerName)
          Unregister a handler.
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, init, setInitableBroker
 

Constructor Detail

TurbineXmlRpcService

public TurbineXmlRpcService()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws InitializationException
This function initializes the XmlRpcService.
Overrides:
init in class TurbineBaseService
Following copied from class: org.apache.turbine.services.TurbineBaseService
Parameters:
config - A ServletConfing to use for initialization activities.
Throws:
InitializationException, - if initialization of this class was not successful.

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 XmlRpcService
Parameters:
handler - The handler to use.
Throws:
XmlRpcException. -  
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 XmlRpcService
Parameters:
handlerName - The name the handler is registered under.
handler - The handler to use.
Throws:
XmlRpcException. -  
IOException. -  

registerHandler

public void registerHandler(java.lang.String handlerName,
                            java.lang.String handlerClass)
                     throws TurbineException
A helper method that tries to initialize a handler and register it. The purpose is to check for all the exceptions that may occur in dynamic class loading and throw an InitializationException on error.
Parameters:
handlerName - The name the handler is registered under.
handlerClass - The name of the class to use as a handler.
Throws:
TurbineException - Couldn't instantiate handler.

unregisterHandler

public void unregisterHandler(java.lang.String handlerName)
Unregister a handler.
Specified by:
unregisterHandler in interface XmlRpcService
Parameters:
handlerName - The name of the handler to unregister.

handleRequest

public byte[] handleRequest(java.io.InputStream is)
Handle an XML-RPC request using the encapsulated server. You can use this method to handle a request from within a Turbine screen.
Specified by:
handleRequest in interface XmlRpcService
Parameters:
is - the stream to read request data from.
Returns:
the response body that needs to be sent to the client.

handleRequest

public byte[] handleRequest(java.io.InputStream is,
                            java.lang.String user,
                            java.lang.String password)
Handle an XML-RPC request using the encapsulated server with user authentication. You can use this method to handle a request from within a Turbine screen.

Note that the handlers need to implement AuthenticatedXmlRpcHandler interface to access the authentication infomration.

Specified by:
handleRequest in interface XmlRpcService
Parameters:
is - the stream to read request data from.
user - the user that is making the request.
password - the password given by user.
Returns:
the response body that needs to be sent to the client.

executeRpc

public java.lang.Object executeRpc(java.net.URL url,
                                   java.lang.String methodName,
                                   java.util.Vector params)
                            throws TurbineException
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 XmlRpcService
Parameters:
url - A URL.
methodName - A String with the method name.
params - A Vector with the parameters.
Returns:
An Object.
Throws:
XmlRpcException. -  
IOException. -  

executeAuthenticatedRpc

public java.lang.Object executeAuthenticatedRpc(java.net.URL url,
                                                java.lang.String username,
                                                java.lang.String password,
                                                java.lang.String methodName,
                                                java.util.Vector params)
                                         throws TurbineException
Client's Authenticated interface to XML-RPC. The return type is Object which you'll need to cast to whatever you are expecting.
Specified by:
executeAuthenticatedRpc in interface XmlRpcService
Parameters:
url - A URL.
username - The username to try and authenticate with
password - The password to try and authenticate with
methodName - A String with the method name.
params - A Vector with the parameters.
Returns:
An Object.
Throws:
XmlRpcException. -  
IOException. -  

send

public void send(java.lang.String serverURL,
                 java.lang.String sourceLocationProperty,
                 java.lang.String sourceFileName,
                 java.lang.String destinationLocationProperty,
                 java.lang.String destinationFileName)
          throws java.lang.Exception
Method to allow a client to send a file to a server.
Specified by:
send in interface XmlRpcService
Parameters:
serverURL -  
sourceLocationProperty -  
sourceFileName -  
destinationLocationProperty -  
destinationFileName -  

send

public void send(java.lang.String serverURL,
                 java.lang.String username,
                 java.lang.String password,
                 java.lang.String sourceLocationProperty,
                 java.lang.String sourceFileName,
                 java.lang.String destinationLocationProperty,
                 java.lang.String destinationFileName)
          throws java.lang.Exception
Method to allow a client to send a file to a server that requires authentication
Specified by:
send in interface XmlRpcService
Parameters:
serverURL -  
username -  
password -  
sourceLocationProperty -  
sourceFileName -  
destinationLocationProperty -  
destinationFileName -  

get

public void get(java.lang.String serverURL,
                java.lang.String sourceLocationProperty,
                java.lang.String sourceFileName,
                java.lang.String destinationLocationProperty,
                java.lang.String destinationFileName)
         throws java.lang.Exception
Method to allow a client to get a file to a server.
Specified by:
get in interface XmlRpcService
Parameters:
serverURL -  
sourceLocationProperty -  
sourceFileName -  
destinationLocationProperty -  
destinationFileName -  

get

public void get(java.lang.String serverURL,
                java.lang.String username,
                java.lang.String password,
                java.lang.String sourceLocationProperty,
                java.lang.String sourceFileName,
                java.lang.String destinationLocationProperty,
                java.lang.String destinationFileName)
         throws java.lang.Exception
Method to allow a client to get a file from a server that requires authentication.
Specified by:
get in interface XmlRpcService
Parameters:
serverURL -  
username -  
password -  
sourceLocationProperty -  
sourceFileName -  
destinationLocationProperty -  
destinationFileName -  

remove

public void remove(java.lang.String serverURL,
                   java.lang.String sourceLocationProperty,
                   java.lang.String sourceFileName)
            throws java.lang.Exception
Method to allow a client to remove a file from the server
Specified by:
remove in interface XmlRpcService
Parameters:
serverURL -  
sourceLocationProperty -  
sourceFileName -  

remove

public void remove(java.lang.String serverURL,
                   java.lang.String username,
                   java.lang.String password,
                   java.lang.String sourceLocationProperty,
                   java.lang.String sourceFileName)
            throws java.lang.Exception
Method to allow a client to remove a file from a server that requires authentication.
Specified by:
remove in interface XmlRpcService
Parameters:
serverURL -  
username -  
password -  
sourceLocationProperty -  
sourceFileName -  

setParanoid

public void setParanoid(boolean state)
Switch client filtering on/off.
Specified by:
setParanoid in interface XmlRpcService
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 XmlRpcService
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 XmlRpcService
Parameters:
address - The address to add to the list.
See Also:
acceptClient(java.lang.String), setParanoid(boolean)

shutdown

public void shutdown()
Shuts down this service, stopping running threads.
Specified by:
shutdown in interface Initable
Overrides:
shutdown in class TurbineBaseService


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