Class DefaultApplicationInitializer
- java.lang.Object
-
- org.java.plugin.boot.DefaultApplicationInitializer
-
- All Implemented Interfaces:
ApplicationInitializer
public class DefaultApplicationInitializer extends java.lang.Object implements ApplicationInitializer
Default implementation of the application initializer interface.Supported configuration parameters:
- org.java.plugin.boot.applicationPlugin
- ID of plug-in to start. There is no default value for this parameter. In common scenario, this is the only parameter that you must provide.
- org.java.plugin.boot.integrityCheckMode
- Regulates how to check plug-ins integrity when running JPF. Possible
values:
full,light,off. The default value isfull. - org.java.plugin.boot.pluginsCollector
- Plug-ins location collector class, for details see
PluginsCollector. Default isDefaultPluginsCollector. - org.java.plugin.boot.pluginsWhiteList
- Location of the file with plug-in identifiers that should be only accepted by this application initializer. This is optional parameter.
- org.java.plugin.boot.pluginsBlackList
- Location of the file with plug-in identifiers that should not be accepted by this application initializer. This is optional parameter.
ObjectFactory.newInstance(ExtendedProperties)when running JPF (see bellow). This allows you to configure JPF precisely.Black and white lists of plug-ins
In some situations you may want to temporary exclude some of your plug-ins from the application scope. This may be achieved with help of while and black lists - simple plain text files that contain lists of plug-in identifiers to be included/excluded from the application. Each identifies should be in separate line. You may provide unique plug-in ID also.
What is application plug-in?
When application starts, the
Boot.main(String[])method executed callinginitApplication(BootErrorHandler, String[])to get initialized instance ofApplication(orServiceApplication) class. The methodinitApplication(BootErrorHandler, String[])in this implementation scans plug-in repositories to collect all available plug-in files and folders (using special class that can be customized), instantiates JPF and publishes all discovered plug-ins. After that it asksPluginManagerfor an Application Plug-in with ID provided as configuration parameter. Returned class instance is expected to be of typeApplicationPluginand it's methodApplicationPlugin.initApplication(ExtendedProperties, String[])called.To the mentioned
initApplicationmethod passed a subset of configuration properties whose names start with application plug-in ID followed with dot character'.'(seeExtendedProperties.getSubset(String)for details).As a result of the described procedure, the
Bootget instance ofApplicationinterface, so it can start application callingApplication.startApplication()method.- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringPARAM_APPLICATION_PLUGINprotected static java.lang.StringPARAM_INTEGRITY_CHECK_MODEprotected static java.lang.StringPARAM_PLUGINS_BLACK_LISTprotected static java.lang.StringPARAM_PLUGINS_COLLECTORprotected static java.lang.StringPARAM_PLUGINS_WHITE_LIST
-
Constructor Summary
Constructors Constructor Description DefaultApplicationInitializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(ExtendedProperties configuration)Configures this instance and application environment.protected java.util.Collection<PluginManager.PluginLocation>filterPluginLocations(PluginRegistry registry, java.util.Collection<PluginManager.PluginLocation> pluginLocations)This method may remove unwanted plug-in locations from the given list.ApplicationinitApplication(BootErrorHandler errorHandler, java.lang.String[] args)Initializes application.protected java.lang.StringintegrityCheckReport2str(IntegrityCheckReport report)
-
-
-
Field Detail
-
PARAM_APPLICATION_PLUGIN
protected static final java.lang.String PARAM_APPLICATION_PLUGIN
- See Also:
- Constant Field Values
-
PARAM_INTEGRITY_CHECK_MODE
protected static final java.lang.String PARAM_INTEGRITY_CHECK_MODE
- See Also:
- Constant Field Values
-
PARAM_PLUGINS_COLLECTOR
protected static final java.lang.String PARAM_PLUGINS_COLLECTOR
- See Also:
- Constant Field Values
-
PARAM_PLUGINS_WHITE_LIST
protected static final java.lang.String PARAM_PLUGINS_WHITE_LIST
- See Also:
- Constant Field Values
-
PARAM_PLUGINS_BLACK_LIST
protected static final java.lang.String PARAM_PLUGINS_BLACK_LIST
- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(ExtendedProperties configuration) throws java.lang.Exception
Configures this instance and application environment. The sequence is:- Configure logging system. There is special code for supporting
Log4jlogging system only. All other systems support come fromcommons-loggingpackage. - Instantiate and configure
PluginsCollectorusing configuration data.
- Specified by:
configurein interfaceApplicationInitializer- Parameters:
configuration- application configuration data fromboot.propertiesfile andSystemproperties as defaults- Throws:
java.lang.Exception- if any error has occurred during initializer configuring- See Also:
ApplicationInitializer.configure( org.java.plugin.util.ExtendedProperties)
- Configure logging system. There is special code for supporting
-
initApplication
public Application initApplication(BootErrorHandler errorHandler, java.lang.String[] args) throws java.lang.Exception
Initializes application. The sequence is:- Collect plug-ins locations using configured
PluginsCollector. - Get
PluginManagerinstance fromObjectFactoryusing codeObjectFactory.newInstance(config).createManager(). - Publish collected plug-ins using
PluginManager.publishPlugins(org.java.plugin.PluginManager.PluginLocation[]). - Check integrity if that's configured.
- Get application plug-in and call it
JpfApplication initApplication(Properties)method. - Return received instance of
Applicationinterface.
- Specified by:
initApplicationin interfaceApplicationInitializer- Parameters:
errorHandler- callback interface to report errors to the user, it is recommended to use this handler only for "non-fatal" errors and ask user viaBootErrorHandler.handleError(String, Exception)orBootErrorHandler.handleError(String, org.java.plugin.registry.IntegrityCheckReport)if he wants to abort application boot processargs- command line arguments as they passed to programmainmethod- Returns:
- initialized application instance or
nullif initializing failed - Throws:
java.lang.Exception- if any error has occurred during application initializing- See Also:
ApplicationInitializer.initApplication( BootErrorHandler, String[])
- Collect plug-ins locations using configured
-
integrityCheckReport2str
protected java.lang.String integrityCheckReport2str(IntegrityCheckReport report)
-
filterPluginLocations
protected java.util.Collection<PluginManager.PluginLocation> filterPluginLocations(PluginRegistry registry, java.util.Collection<PluginManager.PluginLocation> pluginLocations) throws ManifestProcessingException
This method may remove unwanted plug-in locations from the given list. Standard implementation applies black/white lists logic.- Parameters:
registry- plug-in registry to process manifestspluginLocations- collected plug-in locations to be filtered- Throws:
ManifestProcessingException
-
-