Hi,

Here's some patches to TurbineXmlRpcService.java and TurbineResources.master, 
thanks to Daniel's patch to Fulcrum.

Finally, newapp starts without errors using TDK-2.2b3 :)

Regards,

-- Rodney
Index: src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java,v
retrieving revision 1.7
diff -u -r1.7 TurbineXmlRpcService.java
--- src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java	8 Oct 2002 08:48:28 -0000	1.7
+++ src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java	11 Oct 2002 07:18:02 -0000
@@ -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);
Index: conf/master/TurbineResources.master
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-2/conf/master/TurbineResources.master,v
retrieving revision 1.15
diff -u -r1.15 TurbineResources.master
--- conf/master/TurbineResources.master	20 Aug 2002 23:59:33 -0000	1.15
+++ conf/master/TurbineResources.master	11 Oct 2002 07:19:46 -0000
@@ -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
 
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to