new LongOpt("udp", LongOpt.REQUIRED_ARGUMENT, null, 'u'),
new LongOpt("mcast_port", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
new LongOpt("log", LongOpt.REQUIRED_ARGUMENT, null, 'l'),
};
Getopt getopt = new Getopt(programName, args, sopts, lopts);
int code;
String arg;
if (System.getProperty(ServerConfig.SERVER_BIND_ADDRESS) == null)
{
// ServerConfig.SERVER_BIND_ADDRESS could have been defined via
// run.conf and so we don't wanna override that.
props.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
}
while ((code = getopt.getopt()) != -1)
{
switch (code)
{
case ':':
case '?':
// for now both of these should exit with error status
System.exit(1);
break; // for completeness
case 1:
// this will catch non-option arguments
// (which we don't currently care about)
System.err.println(programName +
": unused non-option argument: " +
getopt.getOptarg());
break; // for completeness
case 'h':
// show command line help
System.out.println("usage: " + programName + " [options]");
System.out.println();
System.out.println("options:");
System.out.println(" -h, --help Show this help message");
System.out.println(" -V, --version Show version information");
System.out.println(" -- Stop processing options");
System.out.println(" -D<name>[=<value>] Set a system property");
System.out.println(" -d, --bootdir=<dir> Set the boot patch directory; Must be absolute or url");
System.out.println(" -p, --patchdir=<dir> Set the patch directory; Must be absolute or url");
System.out.println(" -n, --netboot=<url> Boot from net with the given url as base");
System.out.println(" -c, --configuration=<name> Set the server configuration name");
System.out.println(" -B, --bootlib=<filename> Add an extra library to the front bootclasspath");
System.out.println(" -L, --library=<filename> Add an extra library to the loaders classpath");
System.out.println(" -C, --classpath=<url> Add an extra url to the loaders classpath");
System.out.println(" -P, --properties=<url> Load system properties from the given url");
System.out.println(" -b, --host=<host or ip> Bind address for all JBoss services");
System.out.println(" -g, --partition=<name> HA Partition name (default=DefaultDomain)");
System.out.println(" -m, --mcast_port=<ip> UDP multicast port; only used by JGroups");
System.out.println(" -u, --udp=<ip> UDP multicast address");
System.out.println(" -l, --log=<log4j|jdk> Specify the logger plugin type");
System.out.println();
System.exit(0);
break; // for completeness
case 'D':
{
// set a system property
arg = getopt.getOptarg();
String name, value;
int i = arg.indexOf("=");
if (i == -1)
{
name = arg;
value = "true";
}
else
{
name = arg.substring(0, i);
value = arg.substring(i + 1, arg.length());
}
System.setProperty(name, value);
// Ensure setting the old bind.address property also sets the new
// jgroups.bind_addr property, otherwise jgroups may ignore it
if ("bind.address".equals(name))
{
// Wildcard address is not valid for JGroups
String addr = ServerConfigUtil.fixRemoteAddress(value);
System.setProperty("jgroups.bind_addr", addr);
}
else if ("jgroups.bind_addr".equals(name))
{
// Wildcard address is not valid for JGroups
String addr = ServerConfigUtil.fixRemoteAddress(value);
System.setProperty("jgroups.bind_addr", addr);
}
break;
}
case 'd':
// set the boot patch URL
bootURL = makeURL(getopt.getOptarg());
break;
case 'p':
{
// set the patch URL
URL patchURL = makeURL(getopt.getOptarg());
props.put(ServerConfig.PATCH_URL, patchURL.toString());
break;
}
case 'n':
// set the net boot url
arg = getopt.getOptarg();
// make sure there is a trailing '/'
if (!arg.endsWith("/")) arg += "/";
props.put(ServerConfig.HOME_URL, new URL(arg).toString());
break;
case 'c':
// set the server name
arg = getopt.getOptarg();
props.put(ServerConfig.SERVER_NAME, arg);
break;
case 'V':
{
// Package information for org.jboss
Package jbossPackage = Package.getPackage("org.jboss");
// show version information
System.out.println("JBoss " + jbossPackage.getImplementationVersion());
System.out.println();
System.out.println("Distributable under LGPL license.");
System.out.println("See terms of license at gnu.org.");
System.out.println();
System.exit(0);
break; // for completness
}
case 'j':
// Show an error and exit
System.err.println(programName + ": option '-j, --jaxp' no longer supported");
System.exit(1);
break; // for completness
case 'B':
arg = getopt.getOptarg();
bootLibraries.add(arg);
break;
case 'L':
arg = getopt.getOptarg();
extraLibraries.add(arg);
break;
case 'C':
{
URL url = makeURL(getopt.getOptarg());
extraClasspath.add(url);
break;
}
case 'P':
{
// Set system properties from url/file
URL url = makeURL(getopt.getOptarg());
Properties props = System.getProperties();
props.load(url.openConnection().getInputStream());
break;
}
case 'b':
arg = getopt.getOptarg();
props.put(ServerConfig.SERVER_BIND_ADDRESS, arg);
System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, arg);
// used by JGroups; only set if not set via -D so users
// can use a different interface for cluster communication
// There are 2 versions of this property, deprecated bind.address
// and the new version, jgroups.bind_addr
String bindAddress = System.getProperty("bind.address");
if (bindAddress == null)
{
// Wildcard address is not valid for JGroups
bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
System.setProperty("bind.address", bindAddress);
}
bindAddress = System.getProperty("jgroups.bind_addr");
if (bindAddress == null)
{
// Wildcard address is not valid for JGroups
bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
System.setProperty("jgroups.bind_addr", bindAddress);
}
// Set the java.rmi.server.hostname if not set
String rmiHost = System.getProperty("java.rmi.server.hostname");
if( rmiHost == null )
{
rmiHost = ServerConfigUtil.fixRemoteAddress(arg);
System.setProperty("java.rmi.server.hostname", rmiHost);
}
break;
case 'g':
arg = getopt.getOptarg();
props.put(ServerConfig.PARTITION_NAME_PROPERTY, arg);
System.setProperty(ServerConfig.PARTITION_NAME_PROPERTY, arg);
break;
case 'u':
arg = getopt.getOptarg();
props.put(ServerConfig.PARTITION_UDP_PROPERTY, arg);
System.setProperty(ServerConfig.PARTITION_UDP_PROPERTY, arg);
// the new jgroups property name
System.setProperty("jgroups.udp.mcast_addr", arg);
break;
case 'm':
arg = getopt.getOptarg();
props.put(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
System.setProperty(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
break;
case 'l':
{
arg = getopt.getOptarg();
String logPlugin = arg;
if( arg.equalsIgnoreCase("log4j") )
logPlugin = "org.jboss.logging.Log4jLoggerPlugin";
else if( arg.equalsIgnoreCase("jdk") )
logPlugin = "org.jboss.logging.jdk.JDK14LoggerPlugin";