diff --git a/src/helma/main/Server.java b/src/helma/main/Server.java index 64e11cbe..9deac298 100644 --- a/src/helma/main/Server.java +++ b/src/helma/main/Server.java @@ -77,6 +77,9 @@ public class Server implements Runnable { InetAddrPort websrvPort = null; InetAddrPort ajp13Port = null; + // Jetty configuration file + File configFile = null; + // map of server-wide database sources Hashtable dbSources; @@ -105,6 +108,7 @@ public class Server implements Runnable { websrvPort = config.getWebsrvPort(); ajp13Port = config.getAjp13Port(); hopHome = config.getHomeDir(); + configFile = config.getConfigFile(); // create system properties sysProps = new ResourceProperties(); @@ -260,6 +264,8 @@ public class Server implements Runnable { } catch (Exception portx) { throw new Exception("Error parsing AJP1.3 server port property: " + portx); } + } else if (args[i].equals("-c") && ((i + 1) < args.length)) { + config.setConfigFile(new File(args[++i])); } else if (args[i].equals("-i") && ((i + 1) < args.length)) { // eat away the -i parameter which is meant for helma.main.launcher.Main i++; @@ -326,6 +332,7 @@ public class Server implements Runnable { System.out.println("Possible options:"); System.out.println(" -h dir Specify hop home directory"); System.out.println(" -f file Specify server.properties file"); + System.out.println(" -c jetty.xml Specify Jetty XML configuration file"); System.out.println(" -w [ip:]port Specify embedded web server address/port"); System.out.println(" -x [ip:]port Specify XML-RPC address/port"); System.out.println(" -jk [ip:]port Specify AJP13 address/port"); @@ -560,39 +567,41 @@ public class Server implements Runnable { */ public void run() { try { - if ((websrvPort != null) || (ajp13Port != null)) { + if (configFile != null && configFile.exists()) { + http = new org.mortbay.jetty.Server(configFile.toURI().toURL()); + } else if ((websrvPort != null) || (ajp13Port != null)) { http = new HttpServer(); - } - // start embedded web server if port is specified - if (websrvPort != null) { - http.addListener(websrvPort); - } - - // activate the ajp13-listener - if (ajp13Port != null) { - // create AJP13Listener - ajp13 = new AJP13Listener(ajp13Port); - ajp13.setHttpServer(http); - - String jkallow = sysProps.getProperty("allowAJP13"); - - // by default the AJP13-connection just accepts requests from 127.0.0.1 - if (jkallow == null) { - jkallow = "127.0.0.1"; + // start embedded web server if port is specified + if (websrvPort != null) { + http.addListener(websrvPort); } - StringTokenizer st = new StringTokenizer(jkallow, " ,;"); - String[] jkallowarr = new String[st.countTokens()]; - int cnt = 0; + // activate the ajp13-listener + if (ajp13Port != null) { + // create AJP13Listener + ajp13 = new AJP13Listener(ajp13Port); + ajp13.setHttpServer(http); - while (st.hasMoreTokens()) { - jkallowarr[cnt] = st.nextToken(); - cnt++; + String jkallow = sysProps.getProperty("allowAJP13"); + + // by default the AJP13-connection just accepts requests from 127.0.0.1 + if (jkallow == null) { + jkallow = "127.0.0.1"; + } + + StringTokenizer st = new StringTokenizer(jkallow, " ,;"); + String[] jkallowarr = new String[st.countTokens()]; + int cnt = 0; + + while (st.hasMoreTokens()) { + jkallowarr[cnt] = st.nextToken(); + cnt++; + } + + ajp13.setRemoteServers(jkallowarr); + logger.info("Starting AJP13-Listener on port " + (ajp13Port)); } - - ajp13.setRemoteServers(jkallowarr); - logger.info("Starting AJP13-Listener on port " + (ajp13Port)); } if (xmlrpcPort != null) { diff --git a/src/helma/main/ServerConfig.java b/src/helma/main/ServerConfig.java index 9217f868..eab1d2d1 100644 --- a/src/helma/main/ServerConfig.java +++ b/src/helma/main/ServerConfig.java @@ -31,6 +31,7 @@ public class ServerConfig { private InetAddrPort ajp13Port = null; private File propFile = null; private File homeDir = null; + private File configFile = null; public boolean hasPropFile() { return (propFile != null); @@ -103,4 +104,12 @@ public class ServerConfig { public void setHomeDir(File homeDir) { this.homeDir = homeDir == null ? null : homeDir.getAbsoluteFile(); } + + public File getConfigFile() { + return configFile; + } + + public void setConfigFile(File configFile) { + this.configFile = configFile == null ? null : configFile.getAbsoluteFile(); + } }