java.lang.Object
mucode.util.Launcher
- All Implemented Interfaces:
- mucode.MuConstants
- public class Launcher
- extends java.lang.Object
- implements mucode.MuConstants
This class simplifies the task of passing command line parameteres from an
application to a µServer embedded in it. It also provides a
facilities for starting a µServer directly from the command
line.
The class is essentially a wrapper around a µServer. The
method parseArgs 55 allows parsing of command line
arguments.
Command line options start with a dash ("-"). The set of
recognized options is the same as the set of µServer
properties, defined in mucode.MuConstants and explained in MuServer.properties>MuServer.properties 55 . An additional option
-propertyfile is recognized, that allows to load properties
from a configuration file, formatted as explained in loadProperties 55 . This option is mutually exclusive
with standard options: e.g., it is not possible to specify:
java mucode.util.Launcher -propertyfile prop.cfg -debug on
Options setting a value are followed by the value. Flags (e.g.,
"-debug") accept one of the values on and
off.
The method launch 55 parses the command line arguments, and
then starts the run-time support for the µServer, by calling
its boot 55 method.
This class contains a main(), thus a µServer
listening on the specified port can be started directly from command
line.
Example. java mucode.util.Launcher -debug on -port 2000
creates a new Java VM containing a µServer that will listen on
port 2000, and will output debug messages.
- Version:
- 1.0
| Fields inherited from interface mucode.MuConstants |
COMPRESSIONkey, DEBUGkey, DYN_LINK, ERRORSkey, GROUP, MESSAGESkey, OK, PACKAGE_NAME, PORTkey, REMOTE_ERROR, SERVER_PORT, TIMEOUT, TIMEOUTkey, UBICLASSESkey, UBIPACKAGESkey, UNKNOWN |
|
Constructor Summary |
Launcher()
Create a new Launcher, operating on a new
µServer. |
Launcher(mucode.MuServer server)
Create a new Launcher operating on the specified
µServer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
server
private mucode.MuServer server
Launcher
public Launcher()
- Create a new
Launcher, operating on a new
µServer.
Launcher
public Launcher(mucode.MuServer server)
- Create a new
Launcher operating on the specified
µServer.
getServer
public mucode.MuServer getServer()
- Retrieve the µServer this object is operating on.
launch
public void launch(java.lang.String[] args,
int index)
- Parse a set of arguments (typically coming from the command line),
starting at the specified
index, and then start the
µServer associated with this object, by calling its MuServer.boot()>MuServer.boot() 55 method.
parseArgs
public void parseArgs(java.lang.String[] args,
int index)
- Parse an array of
String arguments, usually coming directly
from the command line. Useful when the µServer is embedded
in an application that needs to specify its own arguments and still
needs to provide access to the µServer's options through
the command line. The arguments for the µServer must always
be the last ones in the argument array. Thus, for instance, in
java MyApplication myArg1 myArg2 -debug on -compression on
if a variable String[] args contains the arguments passed to
MyApplication on the command line (e.g., as retrieved from
MyApplication.main(), the µServer object can be
configured with the options by invoking
MuServer s = MuServer();
new Launcher(s).parseArgs(args, 2);
parseMultipleArgs
private java.lang.String[] parseMultipleArgs(java.lang.String[] args,
int start)
isFlag
private boolean isFlag(java.lang.String arg)
parseFlag
private java.lang.String parseFlag(java.lang.String flag)
printHelp
private static void printHelp()
main
public static void main(java.lang.String[] args)
- Create and start a µServer directly from the command
line, by specifying command line options.