You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by th...@apache.org on 2001/03/01 20:10:16 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc TurbineXmlRpcService.java
thorhauer 01/03/01 11:10:15
Modified: src/java/org/apache/turbine/services/xmlrpc
TurbineXmlRpcService.java
Log:
adding ServletConfig to the init signature so that xml rpc service is available
when servlet engine starts
Revision Changes Path
1.13 +37 -33 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java
Index: TurbineXmlRpcService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TurbineXmlRpcService.java 2001/02/24 23:29:14 1.12
+++ TurbineXmlRpcService.java 2001/03/01 19:10:12 1.13
@@ -81,6 +81,10 @@
import helma.xmlrpc.XmlRpcClient;
import helma.xmlrpc.XmlRpcException;
+// Java Servlet Classes
+import javax.servlet.*;
+import javax.servlet.http.*;
+
/**
* This is a service which will make an xml-rpc call to a remote
* server.
@@ -98,7 +102,7 @@
* @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>
- * @version $Id: TurbineXmlRpcService.java,v 1.12 2001/02/24 23:29:14 jvanzyl Exp $
+ * @version $Id: TurbineXmlRpcService.java,v 1.13 2001/03/01 19:10:12 thorhauer Exp $
*/
public class TurbineXmlRpcService
extends TurbineBaseService
@@ -123,11 +127,11 @@
/**
* This function initializes the XmlRpcService.
*/
- public void init() throws InitializationException
+ public void init(ServletConfig config) throws InitializationException
{
try
{
- ResourceService resources =
+ ResourceService resources =
((TurbineServices)TurbineServices.getInstance()).
getResources(getName());
@@ -135,16 +139,16 @@
// Set the port for the service
int port = resources.getInt("port", 0);
-
+
if(port != 0)
{
webserver = new WebServer(port);
- }
+ }
// Set the XML driver to the correct SAX parser class
String saxParserClass = resources.getString("parser",
"org.apache.xerces.parsers.SAXParser");
-
+
XmlRpc.setDriver ( saxParserClass );
// Check if there are any handlers to register at startup
@@ -156,12 +160,12 @@
String handlerClass = resources.getString(handler);
registerHandler(handlerName, handlerClass);
}
-
+
/*
* Turn on paranoia for the webserver if requested.
*/
boolean stateOfParanoia = resources.getBoolean("paranoid", false);
-
+
if (stateOfParanoia)
{
webserver.setParanoid(stateOfParanoia);
@@ -172,43 +176,43 @@
* are in a state of paranoia as they will just
* be ignored so there's no point in setting them.
*/
-
+
/*
* Set the list of clients that can connect
* to the xmlrpc server. The accepted client list
* will only be consulted if we are paranoid.
*/
Vector acceptedClients = resources.getVector("acceptClient");
-
+
for (int i = 0; i < acceptedClients.size(); i++)
{
String acceptClient = (String) acceptedClients.get(i);
-
+
if (acceptClient != null && ! acceptClient.equals(""))
{
webserver.acceptClient(acceptClient);
Log.info(XmlRpcService.SERVICE_NAME + ": Accepting client -> " + acceptClient);
}
}
-
+
/*
* Set the list of clients that can connect
* to the xmlrpc server. The denied client list
* will only be consulted if we are paranoid.
*/
Vector deniedClients = resources.getVector("denyClient");
-
+
for (int i = 0; i < deniedClients.size(); i++)
{
String denyClient = (String) deniedClients.get(i);
-
+
if (denyClient != null && ! denyClient.equals(""))
{
webserver.denyClient(denyClient);
Log.info(XmlRpcService.SERVICE_NAME + ": Denying client -> " + denyClient);
}
}
- }
+ }
}
catch (Exception e)
{
@@ -249,7 +253,7 @@
{
webserver.addHandler(handlerName, handler);
}
-
+
server.addHandler(handlerName, handler);
}
@@ -269,12 +273,12 @@
try
{
Object handler = Class.forName(handlerClass).newInstance();
-
+
if(webserver != null)
{
webserver.addHandler(handlerName,handler);
}
-
+
server.addHandler(handlerName,handler);
}
// those two errors must be passed to the VM
@@ -286,10 +290,10 @@
{
throw t;
}
-
- catch( Throwable t )
+
+ catch( Throwable t )
{
- throw new TurbineException("Failed to instantiate "+handlerClass, t);
+ throw new TurbineException("Failed to instantiate "+handlerClass, t);
}
}
@@ -303,8 +307,8 @@
if(webserver != null)
{
webserver.removeHandler(handlerName);
- }
-
+ }
+
server.removeHandler(handlerName);
}
@@ -337,7 +341,7 @@
* @param password the password given by user.
* @return the response body that needs to be sent to the client.
*/
- public byte[] handleRequest(InputStream is, String user, String password)
+ public byte[] handleRequest(InputStream is, String user, String password)
{
return server.execute(is, user, password);
}
@@ -433,7 +437,7 @@
}
/**
- * Switch client filtering on/off.
+ * Switch client filtering on/off.
* @see acceptClient(java.lang.String)
* @see denyClient(java.lang.String)
*/
@@ -443,10 +447,10 @@
}
/**
- * Add an IP address to the list of accepted clients. The parameter can
- * contain '*' as wildcard character, e.g. "192.168.*.*". You must
+ * 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.
+ * any effect.
*
* @see denyClient(java.lang.String)
* @see setParanoid(boolean)
@@ -455,11 +459,11 @@
{
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.
+ * 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)
@@ -467,5 +471,5 @@
public void denyClient(String address)
{
webserver.denyClient(address);
- }
+ }
}