public class ServerDriver extends CommonDriver
Configuration file can be plain (unencrypted) XML file or encrypted XML. If no password is given with the command line, the file is assumed to be plain XML.
This driver takes an optional name of a bootstrap configuration file, but if not specified, it will default to "standard_server.xml" in the current directory.
All entries in the bootstrap configuration can be overridden by a command line parameter using the "category:group:key=value" syntax (see below).
The bootstrap configuration can specify a custom class as the server
process by using the "applications:class:server" key. If not specified
in the configuration file or on the command line, its value will be
defaulted to StandardServer
.
The full syntax of the command line is:
java ServerDriver [-?]
[-k]
[-s]
[-c]
[-w timeout]
[-b batch-process]
[-j appserver]
[config]
[-p config_file_password]
[[[category:]group:]key=value]...
Arguments can be specified in any order, except for the -? (help) which can only be specified as the first argument.
'-?' requests syntax help and exits.
'-b' will connect to the specified P2J server and attempt to start the specified batch process.
'-j' will connect to the specified P2J server and attempt to start the specified appserver.
'-c' will reconfigure the certificates, keystores and truststores and save them in the directory.
'-k', '-s' and '-w' options all operate on a the specified server (which
is referenced in the bootstrap configuration and/or the command line
configuration overrides). These shift into a special "client" mode to
connect (or attempt to connect) to the specified server. The '-k' will
kill that server as long as the process' identity has "shutdown" rights
on the P2J server. The '-s' queries the status of the server and the
'-w' waits for the server to be in a STATUS_RUNNING
state.
The timeout for the '-w' option is in milliseconds and -1 means to wait
indefinitely. All 3 of these special modes of the driver will always
call System.exit
with a process exit code that is one of the
following (see the named class constants for the values and meanings):
STATUS_RUNNING STATUS_TIMEOUT STATUS_UNKNOWN STATUS_STOPPED
The exit code in each mode is the current state of the server at the end of the requested operation.
Password can be given with the command line or entered interactively. One special value can be used: "?" means interactive password input.
Arguments in the form "category:group:key=value" are bootstrap configuration overrides. They may be used to add or change values of the configuration keys in the specified category and group. A short form of override (one that omits the category and group) is allowed after a long form override and refers to the most recently specified category and group.
Modifier and Type | Class and Description |
---|---|
private static class |
ServerDriver.SingleProcessClient
Provides a separate thread to include a client (user-interface) in the
same JVM as the server.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
appServer
The name of the remote appserver to start.
|
private java.lang.String |
batchProcess
The name of the remote batch process to start.
|
private int |
mode
Flag that allows overriding the default application.
|
private static int |
MODE_RECONFIGURE
Mode flag to reconfigure the server's security data.
|
private static int |
MODE_START
Mode flag to start the server (the default).
|
private static int |
MODE_START_APPSERVER
Mode flag to start an appserver.
|
private static int |
MODE_START_BATCH_PROCESS
Mode flag to start a batch process.
|
private static int |
MODE_STATUS
Mode flag to check if the server is running.
|
private static int |
MODE_STOP
Mode flag to stop the server.
|
private static int |
MODE_WAIT
Mode flag to wait for the server to be running.
|
static int |
STATUS_RUNNING
Status flag indicates a working/running server.
|
static int |
STATUS_STOPPED
Status flag indicates a server that is not currently running.
|
static int |
STATUS_TIMEOUT
Status flag indicates a server which is accepting connections but not
responding to transaction requests.
|
static int |
STATUS_UNKNOWN
Status flag indicates a server which is accepting connections but some
failure occurred during the transaction request that was used to check
the server's status.
|
private int |
timeout
Maximum milliseconds to wait in
MODE_WAIT or -1 for an
infinite wait. |
defCfg, helptxt, maxCfg
Constructor and Description |
---|
ServerDriver() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkConfig(BootstrapConfig bc)
Allows a subclass to check if the given configuration matches any
required values.
|
private Session |
connect(BootstrapConfig bc)
Connect to the specified server on the
localhost . |
private void |
launchAppServer(BootstrapConfig config,
java.lang.String appServer)
Connect to the remote P2J server and send the command to start the appserver.
|
private void |
launchBatchProcess(BootstrapConfig config,
java.lang.String batchProcess)
Connect to the remote P2J server and send the command to start the batch process.
|
static void |
main(java.lang.String[] args)
The command line entry point.
|
protected int |
processArguments(java.lang.String[] args,
int current)
Process arguments for any data or options that are specific to the
subclass.
|
protected void |
start(BootstrapConfig bc)
Runs the primary application using the preprocessed configuration and
target object.
|
protected void |
status(BootstrapConfig bc)
Check on the state of the specified server and report that state by
exiting with a predefined exit code in
System.exit . |
private int |
statusWorker(BootstrapConfig bc)
Check on the state of the specified server and return that state.
|
protected void |
stop(BootstrapConfig bc)
Make a connection to the specified server and then shut that server
down.
|
protected void |
wait(BootstrapConfig bc,
int timeout)
Wait until the specified server is in a running state or the specified
timeout elapsed, whichever comes first.
|
process, processOverrides, processPassword, syntax, testFollowing
public static final int STATUS_RUNNING
public static final int STATUS_TIMEOUT
public static final int STATUS_UNKNOWN
public static final int STATUS_STOPPED
private static final int MODE_START
private static final int MODE_STOP
private static final int MODE_STATUS
private static final int MODE_WAIT
private static final int MODE_START_APPSERVER
private static final int MODE_RECONFIGURE
private static final int MODE_START_BATCH_PROCESS
private int mode
private int timeout
MODE_WAIT
or -1 for an
infinite wait.private java.lang.String appServer
private java.lang.String batchProcess
protected int processArguments(java.lang.String[] args, int current)
CommonDriver.process(java.lang.String[])
and should call the superclass version if
the current parameter is not processed.processArguments
in class CommonDriver
args
- The command line arguments.current
- The current element being processed.protected void checkConfig(BootstrapConfig bc) throws ConfigurationException
checkConfig
in class CommonDriver
bc
- The configuration to be checked.ConfigurationException
protected void start(BootstrapConfig bc) throws java.lang.Exception
start
in class CommonDriver
bc
- The configuration to use.java.lang.Exception
protected void stop(BootstrapConfig bc)
System.exit
.
This method never returns.
bc
- The configuration to use.protected void status(BootstrapConfig bc)
System.exit
.
This method never returns.
bc
- The configuration to use.protected void wait(BootstrapConfig bc, int timeout)
System.exit
.
This method uses polling to detect the STATUS_RUNNING
state! It will also exit in the case where the status of the server
is STATUS_UNKNOWN
or in a timeout case. As long as the
timeout has not occurred and the state is STATUS_STOPPED
,
this method will wait.
This method never returns.
bc
- The configuration to use.timeout
- Number of milliseconds to wait or -1 for an infinite wait.private void launchAppServer(BootstrapConfig config, java.lang.String appServer)
config
- The P2J server configuration.appServer
- The appserver name.private void launchBatchProcess(BootstrapConfig config, java.lang.String batchProcess)
config
- The P2J server configuration.batchProcess
- The batch process name.private int statusWorker(BootstrapConfig bc)
bc
- The configuration to use.private Session connect(BootstrapConfig bc)
localhost
.bc
- The configuration to use.public static void main(java.lang.String[] args)
args
- The array of command-line parameters.