You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2002/10/11 12:27:29 UTC
cvs commit: jakarta-turbine-2/conf TurbineResources.properties
mpoeschl 2002/10/11 03:27:29
Modified: src/java/org/apache/turbine/services/xmlrpc
TurbineXmlRpcService.java
conf/master TurbineResources.master
conf TurbineResources.properties
Log:
Here's some patches to TurbineXmlRpcService.java and TurbineResources.master,
thanks to Daniel's patch to Fulcrum.
-- Rodney Schneider
Revision Changes Path
1.8 +93 -34 jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java
Index: TurbineXmlRpcService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TurbineXmlRpcService.java 8 Oct 2002 08:48:28 -0000 1.7
+++ TurbineXmlRpcService.java 11 Oct 2002 10:27:28 -0000 1.8
@@ -60,10 +60,12 @@
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcServer;
import org.apache.xmlrpc.secure.SecureWebServer;
+import org.apache.xmlrpc.secure.SecurityTool;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.net.URL;
import java.util.Iterator;
import java.util.Vector;
@@ -102,17 +104,29 @@
extends TurbineBaseService
implements XmlRpcService
{
+ /**
+ * Whether a version of Apache's XML-RPC library greater than 1.1
+ * is available.
+ */
+ protected boolean isModernVersion = false;
+
/** The standalone xmlrpc server. */
- private WebServer webserver = null;
+ protected WebServer webserver = null;
/** The encapsulated xmlrpc server. */
- private XmlRpcServer server = null;
+ protected XmlRpcServer server = null;
+
+ /**
+ * The address to listen on. The default of <code>null</code>
+ * indicates all network interfaces on a multi-homed host.
+ */
+ private InetAddress address = null;
/** The xmlrpc client. */
private XmlRpcClient client = null;
/** The port to listen on. */
- private int port = 0;
+ protected int port = 0;
/**
* This function initializes the XmlRpcService.
@@ -123,34 +137,32 @@
{
server = new XmlRpcServer();
- // Set the port for the service
+ // setup JSSE System properties from secure.server.options
+ Configuration secureServerOptions =
+ getConfiguration().subset("secure.server.option");
+ setSystemPropertiesFromConfiguration(secureServerOptions);
+
+ // Host and port information for the WebServer
+ String addr = getConfiguration().getString("address", null);
port = getConfiguration().getInt("port", 0);
if(port != 0)
{
- if (getConfiguration().getBoolean("secure.server", false))
+ if (addr != null && addr.length() > 0)
{
- // Get the values for the JSSE system properties
- // that we must set for use in the SecureWebServer
- // and the URL https connection handler that is
- // used in XmlRpcClient.
-
- Configuration secureServerOptions =
- getConfiguration().subset("secure.server.option");
-
- Iterator i = secureServerOptions.getKeys();
-
- while (i.hasNext())
+ try
{
- String option = (String) i.next();
- String value = secureServerOptions.getString(option);
-
- Log.debug("JSSE option: " + option + " => " + value);
-
- System.setProperty(option, value);
+ address = InetAddress.getByName(addr);
+ }
+ catch (UnknownHostException useDefault)
+ {
+ address = null;
}
+ }
- webserver = new SecureWebServer(port);
+ if (getConfiguration().getBoolean("secure.server", false))
+ {
+ webserver = new SecureWebServer(port, address);
}
else
{
@@ -229,7 +241,23 @@
}
}
}
- webserver.start();
+ // If we have a XML-RPC JAR whose version is greater than the
+ // 1.1 series, the WebServer must be explicitly start()'d.
+ try
+ {
+ Class.forName("org.apache.xmlrpc.XmlRpcRequest");
+ isModernVersion = true;
+ webserver.start();
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ // XmlRpcRequest does not exist in versions 1.1 and lower.
+ // Assume that our WebServer was already started.
+ }
+ Log.debug(XmlRpcService.SERVICE_NAME + ": Using " +
+ "Apache XML-RPC version " +
+ (isModernVersion ?
+ "greater than 1.1" : "1.1 or lower"));
}
catch (Exception e)
{
@@ -241,6 +269,28 @@
}
/**
+ * 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
+ */
+ void setSystemPropertiesFromConfiguration(Configuration configuration)
+ {
+ for( Iterator i = configuration.getKeys();i.hasNext();)
+ {
+ String key = (String) i.next();
+ String value = configuration.getString(key);
+
+ Log.debug("JSSE option: " + key + " => " + value);
+
+ System.setProperty(key, value);
+ }
+ }
+
+ /**
* Register an Object as a default handler for the service.
*
* @param handler The handler to use.
@@ -625,17 +675,26 @@
*/
public void shutdown()
{
- // Stop the XML RPC server. org.apache.xmlrpc.WebServer blocks in a call to
- // ServerSocket.accept() until a socket connection is made.
+ // Stop the XML RPC server.
webserver.shutdown();
- try
- {
- Socket interrupt = new Socket(InetAddress.getLocalHost(), port);
- interrupt.close();
- }
- catch (Exception ignored)
+
+ if (!isModernVersion)
{
- // Remotely possible we're leaving an open listener socket around.
+ // org.apache.xmlrpc.WebServer used to block in a call to
+ // ServerSocket.accept() until a socket connection was made.
+ try
+ {
+ Socket interrupt = new Socket(address, port);
+ interrupt.close();
+ }
+ catch (Exception notShutdown)
+ {
+ // It's remotely possible we're leaving an open listener
+ // socket around.
+ Log.warn(XmlRpcService.SERVICE_NAME +
+ "It's possible the xmlrpc server was not " +
+ "shutdown: " + notShutdown.getMessage());
+ }
}
setInit(false);
1.16 +11 -3 jakarta-turbine-2/conf/master/TurbineResources.master
Index: TurbineResources.master
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/master/TurbineResources.master,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TurbineResources.master 20 Aug 2002 23:59:33 -0000 1.15
+++ TurbineResources.master 11 Oct 2002 10:27:28 -0000 1.16
@@ -806,8 +806,16 @@
services.XmlRpcService.parser=org.apache.xerces.parsers.SAXParser
-# This property specifies which port the server part of the XmlRpc
-# should listen, if it is active.
+# This property specifies which network interface the server part of
+# XmlRpc should bind to (if it is active). If not specified, the
+# server will bind to all addresses configured for your host.
+#
+# Default: 127.0.0.1
+
+#services.XmlRpcService.address=127.0.0.1
+
+# This property specifies which TCP port the web server part of
+# XmlRpc should listen on (if it is active).
#
# Default: 12345
1.16 +14 -6 jakarta-turbine-2/conf/TurbineResources.properties
Index: TurbineResources.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/TurbineResources.properties,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TurbineResources.properties 14 Aug 2002 15:27:07 -0000 1.15
+++ TurbineResources.properties 11 Oct 2002 10:27:29 -0000 1.16
@@ -806,8 +806,16 @@
services.XmlRpcService.parser=org.apache.xerces.parsers.SAXParser
-# This property specifies which port the server part of the XmlRpc
-# should listen, if it is active.
+# This property specifies which network interface the server part of
+# XmlRpc should bind to (if it is active). If not specified, the
+# server will bind to all addresses configured for your host.
+#
+# Default: 127.0.0.1
+
+#services.XmlRpcService.address=127.0.0.1
+
+# This property specifies which TCP port the web server part of
+# XmlRpc should listen on (if it is active).
#
# Default: 12345
@@ -952,7 +960,7 @@
url.case.folding=lower
# -------------------------------------------------------------------
-#
+#
# C O M P O N E N T S E R V I C E
#
# -------------------------------------------------------------------
@@ -969,7 +977,7 @@
services.ComponentService.name = torque
#
-# This is the class of the component to be loaded.
+# This is the class of the component to be loaded.
#
# It must implement the org.apache.stratum.lifecycle.Initializable and
# org.apache.stratum.lifecycle.Configurable interface to be loaded.
@@ -995,7 +1003,7 @@
#
# This is an example of how to load Fulcrum as a component
#
-#services.ComponentService.name = fulcrum
+#services.ComponentService.name = fulcrum
#services.ComponentService.fulcrum.classname = org.apache.fulcrum.Fulcrum
#services.ComponentService.fulcrum.config = /WEB-INF/conf/Fulcrum.properties
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>