Class Boot
jpf.boot.mode
configuration
parameter or System property (via -Djpf.boot.mode=
command line
argument). Supported values are:
- start
- Runs application in "background" ("service") mode.
- stop
- Stops application, running in "background" mode.
- restart
- Restarts application, running in "background" mode. If it is not started, the action is the same as just starting application.
- shell
- Runs application in "shell" (or "interactive") mode. It is possible to control "service" style application from command line. Note, that already running application will be stopped first.
- load
- Only loads application but not starts it as in other modes. This mode is useful when doing application unit testing or when you only need to get initialized and ready to be started JPF environment.
jpf.boot.mode
configuration parameter can be found.
Application configuration is expected to be in Java properties format file. File look-up procedure is the following:
- Check
jpf.boot.config
System property, if present, load configuration from that location - Look for
boot.properties
file in the current folder. - Look for
boot.properties
resource in classpath (usingBoot.class.getClassLoader().getResource("boot.properties")
andBoot.class.getResource("boot.properties")
methods).
If configuration could not be found, a warning will be printed to console. It is generally not an error to not use configuration file, you may provide JPF configuration parameters as System properties. They are always used as defaults for configuration properties.
Note that configuration properties will be loaded using
specially extended
version of Properties
class, which supports parameters
substitution. If there is no applicationRoot
property available
in the given configuration, the current folder will be published as default
value.
Standard configuration parameters are (all are optional when application is running in "shell" mode):
- jpf.boot.mode
- Application boot mode. Always available as System property also.
Default value is
shell
. - org.java.plugin.boot.appInitializer
- Application initializer class, for details see
ApplicationInitializer
. Default isDefaultApplicationInitializer
. - org.java.plugin.boot.errorHandler
- Error handler class, for details see
BootErrorHandler
. Default isBootErrorHandlerConsole
for "service" style applications andBootErrorHandlerGui
for "interactive" applications. - org.java.plugin.boot.controlHost
- Host to be used by background control service, no default values.
- org.java.plugin.boot.controlPort
- Port number to be used by background control service, no default values.
- org.java.plugin.boot.splashHandler
- Splash screen handler class, for details see
SplashHandler
. Default is simple splash handler that can only display an image. - org.java.plugin.boot.splashImage
- Path to an image file to be shown as splash screen. This may be any valid URL. If no file and no handler given, the splash screen will not be shown.
- org.java.plugin.boot.splashLeaveVisible
- If set to
true
, the Boot class will not hide splash screen at the end of boot procedure but delegate this function to application code. Default value isfalse
. - org.java.plugin.boot.splashDisposeOnHide
- If set to
false
, the Boot class will not dispose splash screen handler when hiding it. This allows you to reuse handler and show splash screen back after it was hidden. Default value istrue
.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Name of the file, where to put boot error details.static final String
"load" mode boot command value.static final String
"restart" mode boot command value.static final String
"shell" mode boot command value.static final String
"start" mode boot command value.static final String
"stop" mode boot command value.static final String
Boot configuration file location System property name.static final String
Boot mode System property name. -
Method Summary
Modifier and TypeMethodDescriptionstatic Application
boot
(ExtendedProperties config, boolean useControlService, String mode, BootErrorHandler errorHandler, String[] args) Boots application according to given configuration data.static SplashHandler
Returns current instance of splash screen handler if it is available ornull
.static void
Call this method to start/stop application.static void
setSplashHandler
(SplashHandler handler) static void
stopApplication
(Application application) Stops the application, shuts down plug-in manager and disposes log service.
-
Field Details
-
BOOT_ERROR_FILE_NAME
Name of the file, where to put boot error details.- See Also:
-
PROP_BOOT_CONFIG
Boot configuration file location System property name.- See Also:
-
PROP_BOOT_MODE
Boot mode System property name.- See Also:
-
BOOT_MODE_SHELL
"shell" mode boot command value.- See Also:
-
BOOT_MODE_START
"start" mode boot command value.- See Also:
-
BOOT_MODE_STOP
"stop" mode boot command value.- See Also:
-
BOOT_MODE_RESTART
"restart" mode boot command value.- See Also:
-
BOOT_MODE_LOAD
"load" mode boot command value.- See Also:
-
-
Method Details
-
main
Call this method to start/stop application.- Parameters:
args
- command line arguments, not interpreted by this method but passed toApplicationPlugin.initApplication(ExtendedProperties, String[])
method
-
boot
public static Application boot(ExtendedProperties config, boolean useControlService, String mode, BootErrorHandler errorHandler, String[] args) throws Exception Boots application according to given configuration data.- Parameters:
config
- boot configuration datauseControlService
- iftrue
, the control service will started to allow handling application instance from another processmode
- application run modeerrorHandler
- boot errors handler instanceargs
- command line arguments, not interpreted by this method but passed toApplicationPlugin.initApplication(ExtendedProperties, String[])
method- Returns:
- initialized application instance or
null
- Throws:
Exception
- if any un-handled error has occurred
-
stopApplication
Stops the application, shuts down plug-in manager and disposes log service. Call this method before exiting interactive application. For service applications this method will be called automatically by control service or from shell.- Parameters:
application
- application instance being stopped- Throws:
Exception
- if any error has occurred during application stopping
-
getSplashHandler
Returns current instance of splash screen handler if it is available ornull
.- Returns:
- instance of splash handler or
null
if no active instance available
-
setSplashHandler
- Parameters:
handler
- the new splash handler instance to set ornull
to dispose current handler directly
-