public class ModulesLoader extends Object
PROPKEY_MODULES property which modules will be loaded. These names can then
be used to construct properties that define the classnames and optionally the dependencies of these modules. E.g.
unitils.modules= a, b, c, d
unitils.module.a.className= org.unitils.A
unitils.module.a.runAfter= b, c
unitils.module.b.className= org.unitils.B
unitils.module.b.runAfter= c
unitils.module.c.className= org.unitils.C
unitils.module.d.enabled= false
The above configuration will load 3 core classes A, B and C and will always perform processing in
order C, B, A.
If a circular dependency is found in the runAfter configuration, a runtime exception will be thrown.| Modifier and Type | Field and Description |
|---|---|
static String |
PROPKEY_MODULE_PREFIX
First part of all core specific properties.
|
static String |
PROPKEY_MODULE_SUFFIX_CLASS_NAME
Last part of the core specific property that specifies the classname of the core.
|
static String |
PROPKEY_MODULE_SUFFIX_ENABLED
Last part of the core specific property that specifies whether the core should be loaded.
|
static String |
PROPKEY_MODULE_SUFFIX_RUN_AFTER
Last part of the core specific property that specifies the names of the modules that should be run before this core.
|
static String |
PROPKEY_MODULES
Property that contains the names of the modules that are to be loaded.
|
| Constructor and Description |
|---|
ModulesLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
classFileExistsInClasspath(String className) |
protected List<Module> |
createAndInitializeModules(List<String> moduleNames,
Properties configuration)
Creates the modules with the given class names and calls initializes them with the given configuration.
|
List<Module> |
loadModules(Properties configuration)
Loads all unitils modules as described in the class javadoc.
|
protected void |
removeDisabledModules(Set<String> moduleNames,
Properties configuration)
Removes all modules that have a value false for the enabled property.
|
public static final String PROPKEY_MODULES
public static final String PROPKEY_MODULE_PREFIX
public static final String PROPKEY_MODULE_SUFFIX_ENABLED
public static final String PROPKEY_MODULE_SUFFIX_CLASS_NAME
public static final String PROPKEY_MODULE_SUFFIX_RUN_AFTER
public List<Module> loadModules(Properties configuration)
configuration - the configuration, not nullprotected List<Module> createAndInitializeModules(List<String> moduleNames, Properties configuration)
moduleNames - the module class names, not nullconfiguration - the configuration, not nullprotected void removeDisabledModules(Set<String> moduleNames, Properties configuration)
moduleNames - the module names, not nullconfiguration - the configuration, not nullprotected boolean classFileExistsInClasspath(String className)
className - The name of the class to check, not nullCopyright © 2016. All Rights Reserved.