Common Launcher¶
Table of contents
This handler is the starting point for launching a standalone application.
Initialization of the system repository and execution of the handler queue defined in the repository can be performed by direct launch with a java command.
This handler performs the following processes. See the Javadoc given within the parentheses for the processing details.
- Parsing of command line argument( CommandLine )
- Outputs the launch log( LauncherLogFormatter#getStartLogFormat )
- Initializes the system repository
- Initializes the execution context( Main#setupExecutionContext )
- Outputs the application configuration log( ApplicationSettingLogFormatter )
- Executes the handler queue
- Outputs the log in response to exceptions and errors
- Outputs the end log ( LauncherLogFormatter#getEndLogFormat )
The process flow is as follows.
Module list¶
<dependency>
<groupId>com.nablarch.framework</groupId>
<artifactId>nablarch-fw-standalone</artifactId>
</dependency>
Launch the application¶
Launch the application by specifying Main class.
The following three options must be specified for the framework operation. Terminated immediately if any one of the following options is missing.(Exit code = 127)
- -diConfig
- Specifies the path of the system repository configuration file. Initializes the system repository using the path specified by this option.
- -requestPath
Specifies the action to be executed and the request ID.
Configures a string defined in the following format.
Executable action class name/Request ID
The request path specified by this option is returned by Request#getRequestPath
- -userId
- Configure the user ID.
This value is stored in the session context variable with the name
user.id
.
An execution example is shown below.
java nablarch.fw.launcher.Main \
-diConfig file:./batch-config.xml \
-requestPath admin.DataUnloadBatchAction/BC0012 \
-userId testUser
Configure the options for launching the application¶
During the launch of Main class an any optional parameter can be specified.
Optional parameters are configured in pairs of “option name” and “option value”.
For example, it is specified as shown below when the option name is optionName
and value is optionValue
.
java nablarch.fw.launcher.Main \
-optionName optionValue
To use option in the application, acquire from ExecutionContext .
@Override
public Result handle(String inputData, ExecutionContext ctx) {
// Specify the option name in getSessionScopedVar and acquire the value.
final String value = ctx.getSessionScopedVar("optionName");
// Process
return new Result.Success();
}
Tip
Refer to Launch the application for the options that must be specified while launching the application.
Processing contents according to the exceptions and errors¶
This handler returns the following processes and results depending on the contents of the exceptions and errors that are caught.
Exception class | Processing contents |
---|---|
(including subclass) |
Performs FATAL level log output. After log output, the following values are returned as the process results of the handler.
|
Exception classes other than the above | Performs FATAL level log output. After log output, returns 127 as the process results of the handler. |