Package org.jfree.base.modules
Class PackageManager
java.lang.Object
org.jfree.base.modules.PackageManager
The PackageManager is used to load and configure the modules of JFreeReport.
Modules are used to extend the basic capabilities of JFreeReport by providing
a simple plugin-interface.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe PackageConfiguration handles the module level configuration. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AbstractBootThe boot implementation for which the modules are managed.private final ArrayListA list of module name definitions.private static HashMapThe instances of all modules for all booters.private final ArrayListA list of all defined modules.private final PackageManager.PackageConfigurationThe module configuration instance that should be used to store module properties.private static final intAn internal constant declaring that the specified module produced an error while loading.private static final intAn internal constant declaring that the specified module was already loaded.private static final intAn internal constant declaring that the specified module is not known. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePackageManager(AbstractBoot booter) Creates a new package manager. -
Method Summary
Modifier and TypeMethodDescriptionprivate intacceptVersion(String modVer, String depModVer) Compare the version strings.private booleanacceptVersion(ModuleInfo moduleRequirement, Module module) Checks, whether the given module meets the requirements defined in the module information.voidAdds a module to the package manager.private intcontainsModule(ArrayList tempModules, ModuleInfo module) Checks, whether the given module is already loaded in either the given tempModules list or the global package registry.static PackageManagercreateInstance(AbstractBoot booter) Creates a package manager instance.private voiddropFailedModule(PackageState state) A utility method that collects all failed modules.Module[]Returns all active modules.Module[]Returns an array of the currently active modules.Returns the default package configuration.voidInitializes all previously uninitialized modules.booleanisModuleAvailable(ModuleInfo moduleDescription) Checks, whether a certain module is available.voidLoads all modules mentioned in the report configuration starting with the given prefix.private booleanloadModule(ModuleInfo moduleInfo, ArrayList incompleteModules, ArrayList modules, boolean fatal) Tries to load a given module and all dependent modules.voidPrints the modules that are used.
-
Field Details
-
RETURN_MODULE_LOADED
private static final int RETURN_MODULE_LOADEDAn internal constant declaring that the specified module was already loaded.- See Also:
-
RETURN_MODULE_UNKNOWN
private static final int RETURN_MODULE_UNKNOWNAn internal constant declaring that the specified module is not known.- See Also:
-
RETURN_MODULE_ERROR
private static final int RETURN_MODULE_ERRORAn internal constant declaring that the specified module produced an error while loading.- See Also:
-
packageConfiguration
The module configuration instance that should be used to store module properties. This separates the user defined properties from the implementation defined properties. -
modules
A list of all defined modules. -
initSections
A list of module name definitions. -
booter
The boot implementation for which the modules are managed. -
instances
The instances of all modules for all booters.
-
-
Constructor Details
-
PackageManager
Creates a new package manager.- Parameters:
booter- the booter (nullnot permitted).
-
-
Method Details
-
createInstance
Creates a package manager instance.- Parameters:
booter- the booter.- Returns:
- A package manager.
-
isModuleAvailable
Checks, whether a certain module is available.- Parameters:
moduleDescription- the module description of the desired module.- Returns:
- true, if the module is available and the version of the module is compatible, false otherwise.
-
load
Loads all modules mentioned in the report configuration starting with the given prefix. This method is used during the boot process of JFreeReport. You should never need to call this method directly.- Parameters:
modulePrefix- the module prefix.
-
initializeModules
public void initializeModules()Initializes all previously uninitialized modules. Once a module is initialized, it is not re-initialized a second time. -
addModule
Adds a module to the package manager. Once all modules are added, you have to call initializeModules() to configure and initialize the new modules.- Parameters:
modClass- the module class
-
containsModule
Checks, whether the given module is already loaded in either the given tempModules list or the global package registry. If tmpModules is null, only the previously installed modules are checked.- Parameters:
tempModules- a list of previously loaded modules.module- the module specification that is checked.- Returns:
- true, if the module is already loaded, false otherwise.
-
dropFailedModule
A utility method that collects all failed modules. Such an module caused an error while being loaded, and is now cached in case it is referenced elsewhere.- Parameters:
state- the failed module.
-
loadModule
private boolean loadModule(ModuleInfo moduleInfo, ArrayList incompleteModules, ArrayList modules, boolean fatal) Tries to load a given module and all dependent modules. If the dependency check fails for that module (or for one of the dependent modules), the loaded modules are discarded and no action is taken.- Parameters:
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.- Returns:
- true, if the module was loaded successfully, false otherwise.
-
acceptVersion
Checks, whether the given module meets the requirements defined in the module information.- Parameters:
moduleRequirement- the required module specification.module- the module that should be checked against the specification.- Returns:
- true, if the module meets the given specifications, false otherwise.
-
acceptVersion
Compare the version strings. If the strings have a different length, the shorter string is padded with spaces to make them compareable.- Parameters:
modVer- the version string of the moduledepModVer- the version string of the dependent or optional module- Returns:
- 0, if the dependent module version is equal tothe module's required version, a negative number if the dependent module is newer or a positive number if the dependent module is older and does not fit.
-
getPackageConfiguration
Returns the default package configuration. Private report configuration instances may be inserted here. These inserted configuration can never override the settings from this package configuration.- Returns:
- the package configuration.
-
getAllModules
Returns an array of the currently active modules. The module definition returned contain all known modules, including buggy and unconfigured instances.- Returns:
- the modules.
-
getActiveModules
Returns all active modules. This array does only contain modules which were successfully configured and initialized.- Returns:
- the list of all active modules.
-
printUsedModules
Prints the modules that are used.- Parameters:
p- the print stream.
-