Implement -a switch to helma launcher that allows to explicitly list applications to start, overriding the apps.properties file (application settings in the apps.properties file are still honored, though). Adapt start scripts to pass though additional arguments.
This commit is contained in:
parent
e12c90a529
commit
3a31940fe9
6 changed files with 70 additions and 37 deletions
|
@ -79,7 +79,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
* to create and start new applications.
|
* to create and start new applications.
|
||||||
*/
|
*/
|
||||||
protected void checkForChanges() {
|
protected void checkForChanges() {
|
||||||
if (props.lastModified() > lastModified) {
|
if (props.lastModified() > lastModified && server.getApplicationsOption() == null) {
|
||||||
try {
|
try {
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
||||||
String appName = (String) e.nextElement();
|
String appName = (String) e.nextElement();
|
||||||
|
@ -152,19 +152,27 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
*/
|
*/
|
||||||
public void startAll() {
|
public void startAll() {
|
||||||
try {
|
try {
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
String[] apps = server.getApplicationsOption();
|
||||||
String appName = (String) e.nextElement();
|
if (apps != null) {
|
||||||
|
for (int i = 0; i < apps.length; i++) {
|
||||||
if (appName.indexOf(".") == -1) {
|
AppDescriptor desc = new AppDescriptor(apps[i]);
|
||||||
String appValue = props.getProperty(appName);
|
|
||||||
|
|
||||||
if (appValue != null && appValue.length() > 0) {
|
|
||||||
appName = appValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppDescriptor desc = new AppDescriptor(appName);
|
|
||||||
desc.start();
|
desc.start();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
||||||
|
String appName = (String) e.nextElement();
|
||||||
|
|
||||||
|
if (appName.indexOf(".") == -1) {
|
||||||
|
String appValue = props.getProperty(appName);
|
||||||
|
|
||||||
|
if (appValue != null && appValue.length() > 0) {
|
||||||
|
appName = appValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDescriptor desc = new AppDescriptor(appName);
|
||||||
|
desc.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Enumeration e = descriptors.elements(); e.hasMoreElements();) {
|
for (Enumeration e = descriptors.elements(); e.hasMoreElements();) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.StringTokenizer;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class JettyServer {
|
public class JettyServer {
|
||||||
|
|
||||||
|
@ -36,11 +37,12 @@ public class JettyServer {
|
||||||
// the AJP13 Listener, used for connecting from external webserver to servlet via JK
|
// the AJP13 Listener, used for connecting from external webserver to servlet via JK
|
||||||
protected AJP13Listener ajp13;
|
protected AJP13Listener ajp13;
|
||||||
|
|
||||||
public static JettyServer init(Server server) throws IOException {
|
public static JettyServer init(Server server, ServerConfig config) throws IOException {
|
||||||
if (server.configFile != null && server.configFile.exists()) {
|
File configFile = config.getConfigFile();
|
||||||
return new JettyServer(server.configFile.toURI().toURL());
|
if (configFile != null && configFile.exists()) {
|
||||||
} else if (server.websrvPort != null || server.ajp13Port != null) {
|
return new JettyServer(configFile.toURI().toURL());
|
||||||
return new JettyServer(server.websrvPort, server.ajp13Port, server);
|
} else if (config.hasWebsrvPort() || config.hasAjp13Port()) {
|
||||||
|
return new JettyServer(config.getWebsrvPort(), config.getAjp13Port(), server);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,15 +66,9 @@ public class Server implements Runnable {
|
||||||
private Vector extensions;
|
private Vector extensions;
|
||||||
private Thread mainThread;
|
private Thread mainThread;
|
||||||
|
|
||||||
// server ports
|
// configuration
|
||||||
InetSocketAddress rmiPort = null;
|
ServerConfig config;
|
||||||
InetSocketAddress xmlrpcPort = null;
|
|
||||||
InetSocketAddress websrvPort = null;
|
|
||||||
InetSocketAddress ajp13Port = null;
|
|
||||||
|
|
||||||
// Jetty configuration file
|
|
||||||
File configFile = null;
|
|
||||||
|
|
||||||
// map of server-wide database sources
|
// map of server-wide database sources
|
||||||
Hashtable dbSources;
|
Hashtable dbSources;
|
||||||
|
|
||||||
|
@ -97,12 +91,11 @@ public class Server implements Runnable {
|
||||||
server = this;
|
server = this;
|
||||||
starttime = System.currentTimeMillis();
|
starttime = System.currentTimeMillis();
|
||||||
|
|
||||||
rmiPort = config.getRmiPort();
|
this.config = config;
|
||||||
xmlrpcPort = config.getXmlrpcPort();
|
|
||||||
websrvPort = config.getWebsrvPort();
|
|
||||||
ajp13Port = config.getAjp13Port();
|
|
||||||
hopHome = config.getHomeDir();
|
hopHome = config.getHomeDir();
|
||||||
configFile = config.getConfigFile();
|
if (hopHome == null) {
|
||||||
|
throw new RuntimeException("helma.home property not set");
|
||||||
|
}
|
||||||
|
|
||||||
// create system properties
|
// create system properties
|
||||||
sysProps = new ResourceProperties();
|
sysProps = new ResourceProperties();
|
||||||
|
@ -243,6 +236,8 @@ public class Server implements Runnable {
|
||||||
config.setHomeDir(new File(args[++i]));
|
config.setHomeDir(new File(args[++i]));
|
||||||
} else if (args[i].equals("-f") && ((i + 1) < args.length)) {
|
} else if (args[i].equals("-f") && ((i + 1) < args.length)) {
|
||||||
config.setPropFile(new File(args[++i]));
|
config.setPropFile(new File(args[++i]));
|
||||||
|
} else if (args[i].equals("-a") && ((i + 1) < args.length)) {
|
||||||
|
config.setApps(StringUtils.split(args[++i]));
|
||||||
} else if (args[i].equals("-p") && ((i + 1) < args.length)) {
|
} else if (args[i].equals("-p") && ((i + 1) < args.length)) {
|
||||||
try {
|
try {
|
||||||
config.setRmiPort(getInetSocketAddress(args[++i]));
|
config.setRmiPort(getInetSocketAddress(args[++i]));
|
||||||
|
@ -333,8 +328,9 @@ public class Server implements Runnable {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println("Usage: java helma.main.Server [options]");
|
System.out.println("Usage: java helma.main.Server [options]");
|
||||||
System.out.println("Possible options:");
|
System.out.println("Possible options:");
|
||||||
System.out.println(" -h dir Specify hop home directory");
|
System.out.println(" -a app[,...] Specify applications to start");
|
||||||
System.out.println(" -f file Specify server.properties file");
|
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(" -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");
|
||||||
|
@ -478,7 +474,7 @@ public class Server implements Runnable {
|
||||||
if (sysProps.getProperty("extensions") != null) {
|
if (sysProps.getProperty("extensions") != null) {
|
||||||
initExtensions();
|
initExtensions();
|
||||||
}
|
}
|
||||||
jetty = JettyServer.init(this);
|
jetty = JettyServer.init(this, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -562,7 +558,8 @@ public class Server implements Runnable {
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (xmlrpcPort != null) {
|
if (config.hasXmlrpcPort()) {
|
||||||
|
InetSocketAddress xmlrpcPort = config.getXmlrpcPort();
|
||||||
String xmlparser = sysProps.getProperty("xmlparser");
|
String xmlparser = sysProps.getProperty("xmlparser");
|
||||||
|
|
||||||
if (xmlparser != null) {
|
if (xmlparser != null) {
|
||||||
|
@ -591,7 +588,8 @@ public class Server implements Runnable {
|
||||||
logger.info("Starting XML-RPC server on port " + (xmlrpcPort));
|
logger.info("Starting XML-RPC server on port " + (xmlrpcPort));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rmiPort != null) {
|
if (config.hasRmiPort()) {
|
||||||
|
InetSocketAddress rmiPort = config.getRmiPort();
|
||||||
if (paranoid) {
|
if (paranoid) {
|
||||||
HelmaSocketFactory factory = new HelmaSocketFactory();
|
HelmaSocketFactory factory = new HelmaSocketFactory();
|
||||||
String rallow = sysProps.getProperty("allowWeb");
|
String rallow = sysProps.getProperty("allowWeb");
|
||||||
|
@ -731,6 +729,14 @@ public class Server implements Runnable {
|
||||||
return hopHome;
|
return hopHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the explicit list of apps if started with -a option
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] getApplicationsOption() {
|
||||||
|
return config.getApps();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the main Server instance.
|
* Get the main Server instance.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,11 +32,16 @@ public class ServerConfig {
|
||||||
private File propFile = null;
|
private File propFile = null;
|
||||||
private File homeDir = null;
|
private File homeDir = null;
|
||||||
private File configFile = null;
|
private File configFile = null;
|
||||||
|
private String[] apps = null;
|
||||||
|
|
||||||
public boolean hasPropFile() {
|
public boolean hasPropFile() {
|
||||||
return (propFile != null);
|
return (propFile != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasConfigFile() {
|
||||||
|
return (configFile != null);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasHomeDir() {
|
public boolean hasHomeDir() {
|
||||||
return (homeDir != null);
|
return (homeDir != null);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +62,10 @@ public class ServerConfig {
|
||||||
return (ajp13Port != null);
|
return (ajp13Port != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasApps() {
|
||||||
|
return (apps != null);
|
||||||
|
}
|
||||||
|
|
||||||
public InetSocketAddress getRmiPort() {
|
public InetSocketAddress getRmiPort() {
|
||||||
return rmiPort;
|
return rmiPort;
|
||||||
}
|
}
|
||||||
|
@ -112,4 +121,12 @@ public class ServerConfig {
|
||||||
public void setConfigFile(File configFile) {
|
public void setConfigFile(File configFile) {
|
||||||
this.configFile = configFile == null ? null : configFile.getAbsoluteFile();
|
this.configFile = configFile == null ? null : configFile.getAbsoluteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getApps() {
|
||||||
|
return apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApps(String[] apps) {
|
||||||
|
this.apps = apps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,4 +76,4 @@ if not "%HOP_HOME%"=="" (
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Invoking the Java virtual machine
|
:: Invoking the Java virtual machine
|
||||||
%JAVACMD% %JAVA_OPTIONS% -jar "%INSTALL_DIR%\launcher.jar" %OPTIONS%
|
%JAVACMD% %JAVA_OPTIONS% -jar "%INSTALL_DIR%\launcher.jar" %OPTIONS% %*
|
||||||
|
|
2
start.sh
2
start.sh
|
@ -75,4 +75,4 @@ if [ "$HOP_HOME" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Invoke the Java VM
|
# Invoke the Java VM
|
||||||
$JAVACMD $JAVA_OPTIONS -jar "$INSTALL_DIR/launcher.jar" $SWITCHES
|
$JAVACMD $JAVA_OPTIONS -jar "$INSTALL_DIR/launcher.jar" $SWITCHES $*
|
||||||
|
|
Loading…
Add table
Reference in a new issue