You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/12/24 15:14:35 UTC
cvs commit: jakarta-turbine-fulcrum/xmlrpc/src/test/org/apache/fulcrum/xmlrpc XmlRpcComponentTest.java
epugh 2003/12/24 06:14:35
Modified: xmlrpc project.xml
xmlrpc/src/test TestRoleConfig.xml TestComponentConfig.xml
xmlrpc/xdocs changes.xml
xmlrpc/src/test/org/apache/fulcrum/xmlrpc
XmlRpcComponentTest.java
Added: xmlrpc maven.xml
xmlrpc/src/java/org/apache/fulcrum/xmlrpc
XmlRpcServerComponent.java
DefaultXmlRpcServerComponent.java
DefaultXmlRpcClientComponent.java
XmlRpcClientComponent.java
AbstractXmlRpcComponent.java
Log:
Patch from Ronald to clean up and add modern merlin xdoclet properties
Revision Changes Path
1.6 +14 -7 jakarta-turbine-fulcrum/xmlrpc/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/xmlrpc/project.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- project.xml 7 Dec 2003 18:59:18 -0000 1.5
+++ project.xml 24 Dec 2003 14:14:35 -0000 1.6
@@ -3,16 +3,22 @@
<extend>${basedir}/../project.xml</extend>
<id>fulcrum-xmlrpc</id>
<name>Fulcrum XMLRPC Component</name>
- <currentVersion>1.0-alpha-3</currentVersion>
+ <currentVersion>1.0-alpha-4</currentVersion>
+ <!--contributors>
+ <contributor>
+ <name>Ronald</name>
+ <id>ronald</id>
+ <email>ronald@innovation.ch</email>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </contributor>
+ </contributors-->
+
<dependencies>
<dependency>
- <id>javamail</id>
- <version>1.3</version>
- </dependency>
-
- <dependency>
<id>xmlrpc</id>
<version>1.1</version>
</dependency>
@@ -45,7 +51,8 @@
</dependencies>
<properties>
- <implementation>org.apache.fulcrum.xmlrpc.DefaultXmlRpcComponent</implementation>
+ <implementation>org.apache.fulcrum.xmlrpc.DefaultXmlRpcClientComponent</implementation>
+ <implementation>org.apache.fulcrum.xmlrpc.DefaultXmlRpcServerComponent</implementation>
</properties>
1.1 jakarta-turbine-fulcrum/xmlrpc/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
<preGoal name="java:compile">
<attainGoal name="avalon:meta"/>
</preGoal>
</project>
1.3 +8 -4 jakarta-turbine-fulcrum/xmlrpc/src/test/TestRoleConfig.xml
Index: TestRoleConfig.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/xmlrpc/src/test/TestRoleConfig.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestRoleConfig.xml 1 May 2003 16:59:53 -0000 1.2
+++ TestRoleConfig.xml 24 Dec 2003 14:14:35 -0000 1.3
@@ -1,11 +1,15 @@
<!-- This configuration file for Avalon components is used for testing the TestComponent -->
<role-list>
<role
- name="org.apache.fulcrum.xmlrpc.XmlRpcComponent"
- shorthand="XmlRpcComponent"
- default-class="org.apache.fulcrum.xmlrpc.DefaultXmlRpcComponent"/>
+ name="org.apache.fulcrum.xmlrpc.XmlRpcClientComponent"
+ shorthand="XmlRpcClientComponent"
+ default-class="org.apache.fulcrum.xmlrpc.DefaultXmlRpcClientComponent"/>
+ <role
+ name="org.apache.fulcrum.xmlrpc.XmlRpcServerComponent"
+ shorthand="XmlRpcServerComponent"
+ default-class="org.apache.fulcrum.xmlrpc.DefaultXmlRpcServerComponent"/>
<role
name="org.apache.fulcrum.xmlrpc.TestHandler"
shorthand="TestHandler"
default-class="org.apache.fulcrum.xmlrpc.TestHandlerImpl"/>
-</role-list>
\ No newline at end of file
+</role-list>
1.3 +35 -3 jakarta-turbine-fulcrum/xmlrpc/src/test/TestComponentConfig.xml
Index: TestComponentConfig.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/xmlrpc/src/test/TestComponentConfig.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestComponentConfig.xml 1 May 2003 16:59:53 -0000 1.2
+++ TestComponentConfig.xml 24 Dec 2003 14:14:35 -0000 1.3
@@ -1,5 +1,5 @@
<componentConfig>
- <XmlRpcComponent>
+ <XmlRpcServerComponent>
<!-- Port on which the XML-RPC server will listen for
incoming connections -->
<port>12345</port>
@@ -59,6 +59,38 @@
section has no meaning unless operating in paranoid mode -->
<deniedClients clientIP="10.1.1.*"/>
<deniedClients clientIP="10.1.2.*"/>
- </XmlRpcComponent>
+ </XmlRpcServerComponent>
+ <XmlRpcClientComponent>
+ <!-- Parser implementation to use -->
+ <parser>org.apache.xerces.parsers.SAXParser</parser>
+ <!-- Secure server options -->
+ <systemProperty name="java.protocol.handler.pkgs"
+ value="com.sun.net.ssl.internal.www.protocol" />
+ <systemProperty name="security.provider"
+ value="com.sun.net.ssl.internal.ssl.Provider" />
+ <systemProperty name="security.protocol"
+ value="TLS" />
+ <!-- You probabley want to keep you keyStore and
+ trustStore out of you webapp root -->
+ <systemProperty name="javax.net.ssl.keyStore"
+ value="/tmp/keystore" />
+ <systemProperty name="javax.net.ssl.keyStoreType"
+ value="jks" />
+ <systemProperty name="javax.net.ssl.keyStorePassword"
+ value="password" />
+ <systemProperty name="javax.net.ssl.trustStoreType"
+ value="/tmp/truststore" />
+ <systemProperty name="javax.net.ssl.trustStorePassword"
+ value="password" />
+ <systemProperty name="sun.ssl.keymanager.type"
+ value="SunX509" />
+ <systemProperty name="sun.ssl.trust.manager.type"
+ value="SunX509" />
+ <!-- Set the following values to "all" for debugging -->
+ <systemProperty name="javax.net.debug"
+ value="none" />
+ <systemProperty name="java.security.debug"
+ value="none" />
+ </XmlRpcClientComponent>
<TestHandler/>
-</componentConfig>
\ No newline at end of file
+</componentConfig>
1.1 jakarta-turbine-fulcrum/xmlrpc/src/java/org/apache/fulcrum/xmlrpc/XmlRpcServerComponent.java
Index: XmlRpcServerComponent.java
===================================================================
package org.apache.fulcrum.xmlrpc;
/* ----------------------------------------------------------------------------
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Plexus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ----------------------------------------------------------------------------
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ----------------------------------------------------------------------------
*/
import java.io.IOException;
import org.apache.xmlrpc.XmlRpcException;
/**
* The interface a server-side XmlRpcService implements.
*
* @avalon.service version="1.0"
* @author <a href="mailto:josh@stonecottage.com">Josh Lucas</a>
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: XmlRpcServerComponent.java,v 1.1 2003/12/24 14:14:35 epugh Exp $
*/
public interface XmlRpcServerComponent
{
/** XmlRpcServerComponent. */
public static final String ROLE = XmlRpcServerComponent.class.getName();
/**
* Register an object as a handler for the XmlRpc Server part.
*
* @param handlerName The name under which we want
* to register the service
* @param handler The handler object
* @exception XmlRpcException
* @exception IOException
*/
void registerHandler(String handlerName, Object handler)
throws XmlRpcException, IOException;
/**
* Register an object as a the default handler for
* the XmlRpc Server part.
*
* @param handler The handler object
* @exception XmlRpcException
* @exception IOException
*/
void registerHandler(Object handler)
throws XmlRpcException, IOException;
/**
* Unregister a handler.
*
* @param handlerName The name of the handler to unregister.
*/
void unregisterHandler(String handlerName);
/**
* Switch client filtering on/off.
* @see #acceptClient(java.lang.String)
* @see #denyClient(java.lang.String)
*/
void setParanoid(boolean state);
/**
* 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.
*
* @see #denyClient(java.lang.String)
* @see #setParanoid(boolean)
*/
void acceptClient(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.
*
* @see #acceptClient(java.lang.String)
* @see #setParanoid(boolean)
*/
void denyClient(String address);
}
1.1 jakarta-turbine-fulcrum/xmlrpc/src/java/org/apache/fulcrum/xmlrpc/DefaultXmlRpcServerComponent.java
Index: DefaultXmlRpcServerComponent.java
===================================================================
package org.apache.fulcrum.xmlrpc;
/* ----------------------------------------------------------------------------
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Plexus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ----------------------------------------------------------------------------
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ----------------------------------------------------------------------------
*/
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.xmlrpc.WebServer;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.secure.SecureWebServer;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
/**
* Default implementation of the server-side XML RPC component.
*
* @todo Handle XmlRpc.setDebug(boolean)
*
* @avalon.component version="1.0" name="xmlrpc-server" lifestyle="singleton"
* @avalon.service version="1.0" type="org.apache.fulcrum.xmlrpc.XmlRpcServerComponent"
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: DefaultXmlRpcServerComponent.java,v 1.1 2003/12/24 14:14:35 epugh Exp $
*/
public class DefaultXmlRpcServerComponent
extends AbstractXmlRpcComponent
implements Startable, Disposable, Serviceable, XmlRpcServerComponent
{
/** The service manager for this component. */
private ServiceManager manager;
/** The standalone xmlrpc server. */
private WebServer webserver;
/** The port to listen on. */
private int port;
/** Secure server state. */
private boolean isSecureServer;
/** Paranoid state. */
private boolean isStateOfParanoia;
/** Handlers. */
private Configuration handlerConfiguration;
/** Accepted Clients. */
private Configuration[] acceptedClients;
/** Denied Clients. */
private Configuration[] deniedClients;
/** Default Constructor. */
public DefaultXmlRpcServerComponent()
{
}
// ----------------------------------------------------------------------
// Lifecycle Management
// ----------------------------------------------------------------------
public void configure(Configuration configuration)
throws ConfigurationException
{
super.configure(configuration);
// Set the port for the service
// Need a default value here and make sure we have a valid
// value or throw a config exception.
port = configuration.getChild("port").getValueAsInteger();
getLogger().debug("Server Port: " + port);
// Determine if the server is secure or not.
isSecureServer =
configuration.getChild("secureServer").getValueAsBoolean(false);
getLogger().debug("Secure Server: " + isSecureServer);
// Turn on paranoia for the webserver if requested.
isStateOfParanoia =
configuration.getChild("paranoid").getValueAsBoolean(false);
//!! default value
// Check if there are any handlers to register at startup
handlerConfiguration = configuration.getChild("handlers");
// Set the list of clients that can connect
// to the xmlrpc server. The accepted client list
// will only be consulted if we are paranoid.
acceptedClients = configuration.getChildren("acceptedClients");
// Set the list of clients that can connect
// to the xmlrpc server. The denied client list
// will only be consulted if we are paranoid.
deniedClients = configuration.getChildren("deniedClients");
}
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
* @avalon.dependency key="handler" type="com.apache.xmlrpc.XmlRpcHandler" optional="true"
*/
public void service(ServiceManager manager)
throws ServiceException
{
this.manager = manager;
}
// ------------------------------------------------------------------------
// S T A R T A B L E
// ------------------------------------------------------------------------
public void start()
throws Exception
{
webserver.start();
}
/**
* This function initializes the XmlRpcService.
*/
public void initialize()
throws Exception
{
super.initialize();
getLogger().info( "Attempting to start the XML-RPC server." );
// Need a default value here.
if (isSecureServer)
{
webserver = new SecureWebServer(port);
}
else
{
webserver = new WebServer(port);
}
registerStartupHandlers();
if (isStateOfParanoia)
{
webserver.setParanoid(isStateOfParanoia);
getLogger().info("Operating in a state of paranoia");
// Only set the accept/deny client lists if we
// are in a state of paranoia as they will just
// be ignored so there's no point in setting them.
for (int i = 0; i < acceptedClients.length; i++)
{
Configuration acceptedClient = acceptedClients[i];
String clientIP = acceptedClient.getAttribute("clientIP");
if (clientIP != null && ! clientIP.equals(""))
{
webserver.acceptClient(clientIP);
getLogger().info("Accepting client -> " + clientIP);
}
}
for (int i = 0; i < deniedClients.length; i++)
{
Configuration deniedClient = deniedClients[i];
String clientIP = deniedClient.getAttribute("clientIP");
if (clientIP != null && ! clientIP.equals(""))
{
webserver.denyClient(clientIP);
getLogger().info("Denying client -> " + clientIP);
}
}
}
}
/**
* 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 Exception If there were errors registering a handler.
*/
private void registerStartupHandlers() throws Exception
{
Configuration[] handlers = handlerConfiguration.getChildren("handler");
getLogger().info( "We have " + handlers.length
+ " handlers to configure." );
for (int i = 0; i < handlers.length; i++)
{
Configuration c = handlers[i];
if (c.getName().equals("handler"))
{
String handlerName = c.getChild("name").getValue();
String handlerClass = c.getChild("class").getValue(null);
String handlerRole = c.getChild("role").getValue(null);
if (handlerClass != null && handlerRole == null)
{
registerClassHandler(handlerName, handlerClass);
}
else if (handlerRole != null && handlerClass == null)
{
registerComponentHandler(handlerName, handlerRole);
}
else
{
throw new ConfigurationException(
"Handler must define either a 'class' or 'role'");
}
}
}
}
public void stop()
throws Exception
{
// Stop the XML RPC server. org.apache.xmlrpc.WebServer blocks in a
// call to ServerSocket.accept() until a socket connection is made.
webserver.shutdown();
try
{
Socket interrupt = new Socket(InetAddress.getLocalHost(), port);
interrupt.close();
}
catch (Exception notShutdown)
{
// Remotely possible we're leaving an open listener socket around.
getLogger().warn(
"It's possible the xmlrpc server was not shutdown: "
+ notShutdown.getMessage());
}
}
// ------------------------------------------------------------------------
// D I S P O S A B L E
// ------------------------------------------------------------------------
/**
* Shuts down this service, stopping running threads.
*/
public void dispose()
{
webserver = null;
}
// ------------------------------------------------------------------------
// I M P L E M E N A T I O N
// ------------------------------------------------------------------------
/**
* Register an Object as a default handler for the service.
*
* @param handler The handler to use.
* @exception XmlRpcException
* @exception IOException
*/
public void registerHandler(Object handler)
throws XmlRpcException, IOException
{
registerHandler("$default", handler);
}
/**
* Register an Object as a handler for the service.
*
* @param handlerName The name the handler is registered under.
* @param handler The handler to use.
* @throws XmlRpcException If an XmlRpcException occurs.
* @throws IOException If an IOException occurs.
*/
public void registerHandler(String handlerName,
Object handler)
throws XmlRpcException, IOException
{
webserver.addHandler(handlerName, handler);
}
/**
* 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 Exception on
* error.
*
* @param handlerName The name the handler is registered under.
* @param handlerClass The name of the class to use as a handler.
* @exception Exception Couldn't instantiate handler.
*/
private void registerClassHandler(String handlerName, String handlerClass)
throws Exception
{
try
{
Object handler = getClass().getClassLoader().loadClass(
handlerClass ).newInstance();
webserver.addHandler(handlerName,handler);
getLogger().info("registered: " + handlerName + " with class: "
+ handlerClass);
}
// those two errors must be passed to the VM
catch( ThreadDeath t )
{
throw t;
}
catch( OutOfMemoryError t )
{
throw t;
}
catch( Throwable t )
{
throw new Exception ("Failed to instantiate " + handlerClass, t);
}
}
/**
* Helper that registers a component as a handler with the specified
* handler name.
*
* @param handlerName The name to register this handle as.
* @param handlerRole The role of the component serving as the handler.
* @exception Exception If the component could not be looked up.
*/
private void registerComponentHandler(String handlerName,
String handlerRole)
throws Exception
{
registerHandler(handlerName, manager.lookup(handlerRole));
getLogger().info("registered: " + handlerName + " with component: "
+ handlerRole);
}
/**
* Unregister a handler.
*
* @param handlerName The name of the handler to unregister.
*/
public void unregisterHandler(String handlerName)
{
webserver.removeHandler(handlerName);
}
/**
* Switch client filtering on/off.
*
* @param state Whether to filter clients.
*
* @see #acceptClient(java.lang.String)
* @see #denyClient(java.lang.String)
*/
public void setParanoid(boolean state)
{
webserver.setParanoid(state);
}
/**
* 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.
*
* @param address The address to add to the list.
*
* @see #denyClient(java.lang.String)
* @see #setParanoid(boolean)
*/
public void acceptClient(String address)
{
webserver.acceptClient(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.
*
* @param address The address to add to the list.
*
* @see #acceptClient(java.lang.String)
* @see #setParanoid(boolean)
*/
public void denyClient(String address)
{
webserver.denyClient(address);
}
}
1.1 jakarta-turbine-fulcrum/xmlrpc/src/java/org/apache/fulcrum/xmlrpc/DefaultXmlRpcClientComponent.java
Index: DefaultXmlRpcClientComponent.java
===================================================================
package org.apache.fulcrum.xmlrpc;
/* ----------------------------------------------------------------------------
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Plexus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ----------------------------------------------------------------------------
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ----------------------------------------------------------------------------
*/
import org.apache.xmlrpc.XmlRpcClient;
import java.io.IOException;
import java.net.URL;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcException;
/**
* Default implementation of the client-side XML RPC component.
*
* @avalon.component version="1.0" name="xmlrpc-client" lifestyle="singleton"
* @avalon.service version="1.0" type="org.apache.fulcrum.xmlrpc.XmlRpcClientComponent"
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: DefaultXmlRpcClientComponent.java,v 1.1 2003/12/24 14:14:35 epugh Exp $
*/
public class DefaultXmlRpcClientComponent
extends AbstractXmlRpcComponent
implements XmlRpcClientComponent
{
/** Default Constructor. */
public DefaultXmlRpcClientComponent()
{
}
/**
* Client's interface to XML-RPC.
*
* The return type is Object which you'll need to cast to
* whatever you are expecting.
*
* @param url A URL.
* @param methodName A String with the method name.
* @param params A Vector with the parameters.
* @return An Object.
* @exception XmlRpcException
* @exception IOException
*/
public Object executeRpc(URL url,
String methodName,
Vector params)
throws IOException, XmlRpcException
{
XmlRpcClient client = new XmlRpcClient ( url );
return client.execute(methodName, params);
}
}
1.1 jakarta-turbine-fulcrum/xmlrpc/src/java/org/apache/fulcrum/xmlrpc/XmlRpcClientComponent.java
Index: XmlRpcClientComponent.java
===================================================================
package org.apache.fulcrum.xmlrpc;
/* ----------------------------------------------------------------------------
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Plexus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ----------------------------------------------------------------------------
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ----------------------------------------------------------------------------
*/
import java.io.IOException;
import java.net.URL;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcException;
/**
* The interface a client-side XmlRpcService implements.
*
* @avalon.service version="1.0"
* @author <a href="mailto:josh@stonecottage.com">Josh Lucas</a>
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: XmlRpcClientComponent.java,v 1.1 2003/12/24 14:14:35 epugh Exp $
*/
public interface XmlRpcClientComponent
{
/** XmlRpcClientComponent. */
public static final String ROLE = XmlRpcClientComponent.class.getName();
/**
* Execute a remote procedure call.
*
* @param url A URL.
* @param methodName A String with the method name.
* @param params A Vector with the parameters.
* @return An Object.
* @exception XmlRpcException
* @exception IOException
*/
Object executeRpc(URL url,
String methodName,
Vector params)
throws IOException, XmlRpcException;
}
1.1 jakarta-turbine-fulcrum/xmlrpc/src/java/org/apache/fulcrum/xmlrpc/AbstractXmlRpcComponent.java
Index: AbstractXmlRpcComponent.java
===================================================================
package org.apache.fulcrum.xmlrpc;
/* ----------------------------------------------------------------------------
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Plexus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ----------------------------------------------------------------------------
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ----------------------------------------------------------------------------
*/
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.xmlrpc.XmlRpc;
/**
* Common code for the XML RPC components. This processes the system-properties and parser entries
* from the config.
*
* @todo Handle XmlRpc.setDebug(boolean)
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id: AbstractXmlRpcComponent.java,v 1.1 2003/12/24 14:14:35 epugh Exp $
*/
public abstract class AbstractXmlRpcComponent
extends AbstractLogEnabled
implements Configurable, Initializable
{
/** SAX Parser class. */
protected String saxParserClass;
protected AbstractXmlRpcComponent()
{
}
// ----------------------------------------------------------------------
// Lifecycle Management
// ----------------------------------------------------------------------
public void configure(Configuration configuration)
throws ConfigurationException
{
// Set system properties. These are required if you're
// using SSL.
setSystemPropertiesFromConfiguration(configuration);
// Set the XML driver to the correct SAX parser class
saxParserClass = configuration.getChild("parser").getValue("org.apache.xerces.parsers.SAXParser");
}
/**
* 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.
*
* @param configuration the Configuration defining the System
* properties to be set
*/
protected void setSystemPropertiesFromConfiguration(Configuration configuration)
throws ConfigurationException
{
Configuration[] systemProperties =
configuration.getChildren("systemProperty");
getLogger().debug("system properties: " + systemProperties.length);
for( int i = 0; i < systemProperties.length; i++ )
{
Configuration systemProperty = systemProperties[i];
String key = systemProperty.getAttribute("name");
String value = systemProperty.getAttribute("value");
getLogger().debug("System property: " + key + " => " + value);
System.setProperty(key, value);
}
}
/**
* This function initializes the XmlRpcService.
*/
public void initialize()
throws Exception
{
XmlRpc.setDriver ( saxParserClass );
}
}
1.2 +4 -0 jakarta-turbine-fulcrum/xmlrpc/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/xmlrpc/xdocs/changes.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- changes.xml 9 Sep 2003 16:24:54 -0000 1.1
+++ changes.xml 24 Dec 2003 14:14:35 -0000 1.2
@@ -8,6 +8,10 @@
<body>
<release version="Not applicable" date="">
+ <action dev="ronald" type="add">
+ Add merlin meta info generation. Refactor common code between server and
+ client.
+ </action>
<action dev="quintonm" type="add">
XML-RPC component was added.
</action>
1.4 +19 -16 jakarta-turbine-fulcrum/xmlrpc/src/test/org/apache/fulcrum/xmlrpc/XmlRpcComponentTest.java
Index: XmlRpcComponentTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/xmlrpc/src/test/org/apache/fulcrum/xmlrpc/XmlRpcComponentTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XmlRpcComponentTest.java 9 Sep 2003 16:24:54 -0000 1.3
+++ XmlRpcComponentTest.java 24 Dec 2003 14:14:35 -0000 1.4
@@ -1,10 +1,10 @@
package org.apache.fulcrum.xmlrpc;
+import java.net.URL;
import java.util.Vector;
import org.apache.fulcrum.testcontainer.BaseUnitTest;
import org.apache.avalon.framework.component.ComponentException;
-import org.apache.xmlrpc.XmlRpcClient;
import junit.framework.TestSuite;
@@ -16,7 +16,6 @@
*/
public class XmlRpcComponentTest extends BaseUnitTest
{
-
/**
* Constructor for test.
*
@@ -45,10 +44,10 @@
public void OFFtestLookup()
{
- XmlRpcComponent xmlrpc = null;
+ XmlRpcServerComponent xmlrpc = null;
try
{
- xmlrpc = (XmlRpcComponent) lookup(XmlRpcComponent.ROLE);
+ xmlrpc = (XmlRpcServerComponent) lookup(XmlRpcServerComponent.ROLE);
}
catch (ComponentException e)
{
@@ -60,10 +59,10 @@
public void testHandler() throws Exception
{
// start the xml-rpc server
- XmlRpcComponent xmlrpc = null;
+ XmlRpcServerComponent xmlrpc = null;
try
{
- xmlrpc = (XmlRpcComponent) lookup(XmlRpcComponent.ROLE);
+ xmlrpc = (XmlRpcServerComponent) lookup(XmlRpcServerComponent.ROLE);
}
catch (ComponentException e)
{
@@ -72,8 +71,17 @@
}
// create the client
- XmlRpcClient rpcClient =
- new XmlRpcClient("http://localhost:12345/RPC2");
+ XmlRpcClientComponent rpcClient = null;
+ try
+ {
+ rpcClient = (XmlRpcClientComponent) lookup(XmlRpcClientComponent.ROLE);
+ }
+ catch (ComponentException e)
+ {
+ e.printStackTrace();
+ fail("Could not lookup component");
+ }
+ URL server = new URL("http://localhost:12345/RPC2");
// setup param from rpc call
Vector params = new Vector();
@@ -81,18 +89,13 @@
params.addElement(testMessage);
// test calling the component handler
- String result = (String) rpcClient.execute("ComponentHandler.echo",
+ String result = (String) rpcClient.executeRpc(server, "ComponentHandler.echo",
params);
assertEquals(result, testMessage);
// test calling the class handler
- result = (String) rpcClient.execute("ClassHandler.echo",
+ result = (String) rpcClient.executeRpc(server, "ClassHandler.echo",
params);
assertEquals(result, testMessage);
-
-
-
-
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org