public final class PackageManager
extends java.lang.Object
Modules provide a simple capability to remove unneeded functionality from the JFreeReport system and to reduce the overall code size. The modularisation provides a very strict way of removing unnecessary dependencies between the various packages.
The package manager can be used to add new modules to the system or to check the existence and state of installed modules.
Modifier and Type | Class and Description |
---|---|
static class |
PackageManager.PackageConfiguration
The PackageConfiguration handles the module level configuration.
|
Modifier and Type | Field and Description |
---|---|
private AbstractBoot |
booter
The boot implementation for which the modules are managed.
|
private java.util.ArrayList |
initSections
A list of module name definitions.
|
private static java.util.HashMap |
instances
The instances of all modules for all booters.
|
private java.util.ArrayList |
modules
A list of all defined modules.
|
private PackageManager.PackageConfiguration |
packageConfiguration
The module configuration instance that should be used to store module
properties.
|
private static int |
RETURN_MODULE_ERROR
An internal constant declaring that the specified module produced an error while loading.
|
private static int |
RETURN_MODULE_LOADED
An internal constant declaring that the specified module was already loaded.
|
private static int |
RETURN_MODULE_UNKNOWN
An internal constant declaring that the specified module is not known.
|
Modifier | Constructor and Description |
---|---|
private |
PackageManager(AbstractBoot booter)
Creates a new package manager.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
acceptVersion(ModuleInfo moduleRequirement,
Module module)
Checks, whether the given module meets the requirements defined in the module
information.
|
private int |
acceptVersion(java.lang.String modVer,
java.lang.String depModVer)
Compare the version strings.
|
void |
addModule(java.lang.String modClass)
Adds a module to the package manager.
|
private int |
containsModule(java.util.ArrayList tempModules,
ModuleInfo module)
Checks, whether the given module is already loaded in either the given
tempModules list or the global package registry.
|
static PackageManager |
createInstance(AbstractBoot booter)
Creates a package manager instance.
|
private void |
dropFailedModule(PackageState state)
A utility method that collects all failed modules.
|
Module[] |
getActiveModules()
Returns all active modules.
|
Module[] |
getAllModules()
Returns an array of the currently active modules.
|
PackageManager.PackageConfiguration |
getPackageConfiguration()
Returns the default package configuration.
|
void |
initializeModules()
Initializes all previously uninitialized modules.
|
boolean |
isModuleAvailable(ModuleInfo moduleDescription)
Checks, whether a certain module is available.
|
void |
load(java.lang.String modulePrefix)
Loads all modules mentioned in the report configuration starting with
the given prefix.
|
private boolean |
loadModule(ModuleInfo moduleInfo,
java.util.ArrayList incompleteModules,
java.util.ArrayList modules,
boolean fatal)
Tries to load a given module and all dependent modules.
|
void |
printUsedModules(java.io.PrintStream p)
Prints the modules that are used.
|
private static final int RETURN_MODULE_LOADED
private static final int RETURN_MODULE_UNKNOWN
private static final int RETURN_MODULE_ERROR
private final PackageManager.PackageConfiguration packageConfiguration
private final java.util.ArrayList modules
private final java.util.ArrayList initSections
private AbstractBoot booter
private static java.util.HashMap instances
private PackageManager(AbstractBoot booter)
booter
- the booter (null
not permitted).public static PackageManager createInstance(AbstractBoot booter)
booter
- the booter.public boolean isModuleAvailable(ModuleInfo moduleDescription)
moduleDescription
- the module description of the desired module.public void load(java.lang.String modulePrefix)
modulePrefix
- the module prefix.public void initializeModules()
public void addModule(java.lang.String modClass)
modClass
- the module classprivate int containsModule(java.util.ArrayList tempModules, ModuleInfo module)
tempModules
- a list of previously loaded modules.module
- the module specification that is checked.private void dropFailedModule(PackageState state)
state
- the failed module.private boolean loadModule(ModuleInfo moduleInfo, java.util.ArrayList incompleteModules, java.util.ArrayList modules, boolean fatal)
moduleInfo
- the module info of the module that should be loaded.incompleteModules
- a list of incompletly loaded modules. This are module
specifications which depend on the current module and wait for the module to
be completly loaded.modules
- the list of previously loaded modules for this module.fatal
- a flag that states, whether the failure of loading a module should
be considered an error. Root-modules load errors are never fatal, as we try
to load all known modules, regardless whether they are active or not.private boolean acceptVersion(ModuleInfo moduleRequirement, Module module)
moduleRequirement
- the required module specification.module
- the module that should be checked against the specification.private int acceptVersion(java.lang.String modVer, java.lang.String depModVer)
modVer
- the version string of the moduledepModVer
- the version string of the dependent or optional modulepublic PackageManager.PackageConfiguration getPackageConfiguration()
public Module[] getAllModules()
public Module[] getActiveModules()
public void printUsedModules(java.io.PrintStream p)
p
- the print stream.