More merges from trunk:

r9334: Make location of db.properties customizable using the dbPropFile server property.
r9337: Patch from Tobi Schäfer to pass Jetty XML configuration file to Helma server.
This commit is contained in:
hns 2008-10-21 13:57:50 +00:00
parent d1f972591f
commit 8838238c95
2 changed files with 54 additions and 29 deletions

View file

@ -74,6 +74,9 @@ public class Server implements Runnable {
InetAddrPort websrvPort = null; InetAddrPort websrvPort = null;
InetAddrPort ajp13Port = null; InetAddrPort ajp13Port = null;
// Jetty configuration file
File configFile = null;
// map of server-wide database sources // map of server-wide database sources
Hashtable dbSources; Hashtable dbSources;
@ -102,6 +105,7 @@ public class Server implements Runnable {
websrvPort = config.getWebsrvPort(); websrvPort = config.getWebsrvPort();
ajp13Port = config.getAjp13Port(); ajp13Port = config.getAjp13Port();
hopHome = config.getHomeDir(); hopHome = config.getHomeDir();
configFile = config.getConfigFile();
// create system properties // create system properties
sysProps = new ResourceProperties(); sysProps = new ResourceProperties();
@ -257,6 +261,8 @@ public class Server implements Runnable {
} catch (Exception portx) { } catch (Exception portx) {
throw new Exception("Error parsing AJP1.3 server port property: " + 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)) { } else if (args[i].equals("-i") && ((i + 1) < args.length)) {
// eat away the -i parameter which is meant for helma.main.launcher.Main // eat away the -i parameter which is meant for helma.main.launcher.Main
i++; i++;
@ -323,6 +329,7 @@ public class Server implements Runnable {
System.out.println("Possible options:"); System.out.println("Possible options:");
System.out.println(" -h dir Specify hop home directory"); System.out.println(" -h dir Specify hop home directory");
System.out.println(" -f file Specify server.properties file"); 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(" -w [ip:]port Specify embedded web server address/port");
System.out.println(" -x [ip:]port Specify XML-RPC address/port"); System.out.println(" -x [ip:]port Specify XML-RPC address/port");
System.out.println(" -jk [ip:]port Specify AJP13 address/port"); System.out.println(" -jk [ip:]port Specify AJP13 address/port");
@ -435,14 +442,21 @@ public class Server implements Runnable {
// read db.properties file in helma home directory // read db.properties file in helma home directory
String dbPropfile = sysProps.getProperty("dbPropFile");
File file;
if ((dbPropfile != null) && !"".equals(dbPropfile.trim())) {
file = new File(dbPropfile);
} else {
file = new File(hopHome, "db.properties");
}
dbProps = new ResourceProperties(); dbProps = new ResourceProperties();
dbProps.setIgnoreCase(false); dbProps.setIgnoreCase(false);
dbProps.addResource(new FileResource(new File(hopHome, "db.properties"))); dbProps.addResource(new FileResource(file));
DbSource.setDefaultProps(dbProps); DbSource.setDefaultProps(dbProps);
// read apps.properties file // read apps.properties file
String appsPropfile = sysProps.getProperty("appsPropFile"); String appsPropfile = sysProps.getProperty("appsPropFile");
File file;
if ((appsPropfile != null) && !"".equals(appsPropfile.trim())) { if ((appsPropfile != null) && !"".equals(appsPropfile.trim())) {
file = new File(appsPropfile); file = new File(appsPropfile);
} else { } else {
@ -559,9 +573,10 @@ public class Server implements Runnable {
*/ */
public void run() { public void run() {
try { 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(); http = new HttpServer();
}
// start embedded web server if port is specified // start embedded web server if port is specified
if (websrvPort != null) { if (websrvPort != null) {
@ -593,6 +608,7 @@ public class Server implements Runnable {
ajp13.setRemoteServers(jkallowarr); ajp13.setRemoteServers(jkallowarr);
logger.info("Starting AJP13-Listener on port " + (ajp13Port)); logger.info("Starting AJP13-Listener on port " + (ajp13Port));
} }
}
if (xmlrpcPort != null) { if (xmlrpcPort != null) {
String xmlparser = sysProps.getProperty("xmlparser"); String xmlparser = sysProps.getProperty("xmlparser");

View file

@ -31,6 +31,7 @@ public class ServerConfig {
private InetAddrPort ajp13Port = null; private InetAddrPort ajp13Port = null;
private File propFile = null; private File propFile = null;
private File homeDir = null; private File homeDir = null;
private File configFile = null;
public boolean hasPropFile() { public boolean hasPropFile() {
return (propFile != null); return (propFile != null);
@ -103,4 +104,12 @@ public class ServerConfig {
public void setHomeDir(File homeDir) { public void setHomeDir(File homeDir) {
this.homeDir = homeDir == null ? null : homeDir.getAbsoluteFile(); this.homeDir = homeDir == null ? null : homeDir.getAbsoluteFile();
} }
public File getConfigFile() {
return configFile;
}
public void setConfigFile(File configFile) {
this.configFile = configFile == null ? null : configFile.getAbsoluteFile();
}
} }