diff --git a/src/helma/main/ApplicationManager.java b/src/helma/main/ApplicationManager.java index 68c588ee..09b378b6 100644 --- a/src/helma/main/ApplicationManager.java +++ b/src/helma/main/ApplicationManager.java @@ -134,9 +134,12 @@ public class ApplicationManager { Server.getLogger().log ("Stopping application "+appName); try { Application app = (Application) applications.get (appName); - if (server.http == null) { + // unbind from RMI server + if (port > 0) { Naming.unbind ("//:"+port+"/"+appName); - } else { + } + // unbind from Jetty HTTP server + if (server.http != null) { String mountpoint = mountpoints.getProperty (appName); HttpContext context = server.http.getContext (null, mountpoint); if (context != null) { @@ -156,9 +159,12 @@ public class ApplicationManager { try { Server.getLogger().log ("Binding application "+appName); Application app = (Application) applications.get (appName); - if (server.http == null) { - Naming.rebind ("//:"+port+"/"+appName, app); - } else { + // bind to RMI server + if (port > 0) { + Naming.rebind ("//:"+port+"/"+appName, new RemoteApplication (app)); + } + // bind to Jetty HTTP server + if (server.http != null) { String mountpoint = getMountpoint (appName); // if using embedded webserver (not AJP) set application URL prefix if (server.ajp13Port == 0) diff --git a/src/helma/main/Server.java b/src/helma/main/Server.java index f95210b5..0050de43 100644 --- a/src/helma/main/Server.java +++ b/src/helma/main/Server.java @@ -44,8 +44,8 @@ import org.mortbay.http.ajp.*; static SystemProperties sysProps; // server ports - int rmiPort = 5055; - int xmlrpcPort = 5056; + int rmiPort = 0; + int xmlrpcPort = 0; int websrvPort = 0; int ajp13Port = 0; @@ -222,13 +222,24 @@ import org.mortbay.http.ajp.*; dbSources = new Hashtable (); + // check server ports. If no port is set, + // use 5055 for RMI and 5056 for XML-RPC. + if ((websrvPort | ajp13Port | rmiPort) == 0) { + rmiPort = 5055; + if (xmlrpcPort == 0) + xmlrpcPort = 5056; + } + + // check if servers are already running on the given ports try { - // check if servers are already running on the given ports - if (websrvPort==0) - checkRunning (rmiPort); - else + if (websrvPort > 0) checkRunning (websrvPort); - checkRunning (xmlrpcPort); + if (rmiPort > 0) + checkRunning (rmiPort); + if (xmlrpcPort > 0) + checkRunning (xmlrpcPort); + if (ajp13Port > 0) + checkRunning (ajp13Port); } catch (Exception running) { System.out.println (running.getMessage ()); System.exit (1); @@ -258,7 +269,7 @@ import org.mortbay.http.ajp.*; mainThread = new Thread (this); mainThread.start (); } - + /** * The main method of the Server. Basically, we set up Applications and than @@ -315,7 +326,7 @@ import org.mortbay.http.ajp.*; String xmlparser = sysProps.getProperty ("xmlparser"); if (xmlparser != null) XmlRpc.setDriver (xmlparser); - // XmlRpc.setDebug (true); + xmlrpc = new WebServer (xmlrpcPort); if (paranoid) { xmlrpc.setParanoid (true); @@ -341,7 +352,7 @@ import org.mortbay.http.ajp.*; RMISocketFactory.setSocketFactory (factory); } - if (http == null) { + if (rmiPort > 0) { getLogger().log ("Starting RMI server on port "+rmiPort); LocateRegistry.createRegistry (rmiPort); } @@ -361,10 +372,6 @@ import org.mortbay.http.ajp.*; appManager.startAll (); // start embedded web server - /* if (websrv != null) { - Thread webthread = new Thread (websrv, "WebServer"); - webthread.start (); - } */ if (http != null) try { http.start (); } catch (MultiException m) {