Class AbstractModule
- java.lang.Object
-
- org.pentaho.reporting.libraries.base.boot.DefaultModuleInfo
-
- org.pentaho.reporting.libraries.base.boot.AbstractModule
-
- All Implemented Interfaces:
Module
,ModuleInfo
public abstract class AbstractModule extends DefaultModuleInfo implements Module
The abstract module provides a default implementation of the module interface. The module can be specified in an external property file. The file name of this specification defaults to "module.properties". The first and mandatory section is always the module info and contains the basic module properties like name, version and a short description.module.name: xls-export-gui module.producer: The JFreeReport project - www.jfree.org/jfreereport module.description: A dialog component for the Excel table export. module.version.major: 0 module.version.minor: 84 module.version.patchlevel: 0
The properties name, producer and description are simple strings. They may span multiple lines, but may not contain a colon (':'). The version properties are integer values. This section may be followed by one or more "depends" sections. These sections describe the base modules that are required to be active to make this module work. The package manager will enforce this policy and will deactivate this module if one of the base modules is missing.dependency.module-id.module: org.pentaho.reporting.engine.classic.core.modules.output.table.xls.XLSTableModule dependency.module-id.version.major: 0 dependency.module-id.version.minor: 84
The property *.module references to the module implementation of the module package. The module-id is a per-module-definition-unique identifier and it is recommended to set it to the referenced module's name for documentary purposes.- Author:
- Thomas Morgner
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractModule()
Default Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
configure(SubSystem subSystem)
Configures the module by loading the configuration properties and adding them to the package configuration.String
getDescription()
Returns the module description.String
getName()
Returns the name of this module.ModuleInfo[]
getOptionalModules()
Returns a copy of the required modules array.String
getProducer()
Returns the producer of the module.ModuleInfo[]
getRequiredModules()
Returns a copy of the required modules array.String
getSubSystem()
Returns the modules subsystem.protected static boolean
isClassLoadable(String name, Class<?> context)
Tries to load a class to indirectly check for the existence of a certain library.protected void
loadModuleInfo()
Loads the default module description from the file "module.properties".protected void
loadModuleInfo(InputStream in)
Loads the module description from the given input stream.protected void
performExternalInitialize(String classname)
Deprecated.Use the method that provides a class-context instead.protected void
performExternalInitialize(String classname, Class<?> context)
Executes an weakly referenced external initializer.protected void
setDescription(String description)
Defines the description of the module.protected void
setName(String name)
Defines the name of the module.void
setOptionalModules(ModuleInfo[] optionalModules)
Defines the optional module descriptions for this module.protected void
setProducer(String producer)
Defines the producer of the module.protected void
setRequiredModules(ModuleInfo[] requiredModules)
Defines the required module descriptions for this module.protected void
setSubSystem(String name)
Defines the subsystem name for this module.String
toString()
Returns a string representation of this module.-
Methods inherited from class org.pentaho.reporting.libraries.base.boot.DefaultModuleInfo
equals, getMajorVersion, getMinorVersion, getModuleClass, getPatchLevel, hashCode, setMajorVersion, setMinorVersion, setModuleClass, setPatchLevel
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.pentaho.reporting.libraries.base.boot.Module
initialize
-
Methods inherited from interface org.pentaho.reporting.libraries.base.boot.ModuleInfo
getMajorVersion, getMinorVersion, getModuleClass, getPatchLevel
-
-
-
-
Method Detail
-
loadModuleInfo
protected void loadModuleInfo() throws ModuleInitializeException
Loads the default module description from the file "module.properties". This file must be in the same package as the implementing class.- Throws:
ModuleInitializeException
- if an error occurs.
-
loadModuleInfo
protected void loadModuleInfo(InputStream in) throws ModuleInitializeException
Loads the module description from the given input stream. The module description must conform to the rules define in the class description. The file must be encoded with "ISO-8859-1" (like property files).- Parameters:
in
- the input stream from where to read the file- Throws:
ModuleInitializeException
- if an error occurs.
-
getName
public String getName()
Returns the name of this module.- Specified by:
getName
in interfaceModule
- Returns:
- the module name
- See Also:
Module.getName()
-
setName
protected void setName(String name)
Defines the name of the module.- Parameters:
name
- the module name.
-
getDescription
public String getDescription()
Returns the module description.- Specified by:
getDescription
in interfaceModule
- Returns:
- the description of the module.
- See Also:
Module.getDescription()
-
setDescription
protected void setDescription(String description)
Defines the description of the module.- Parameters:
description
- the module's desciption.
-
getProducer
public String getProducer()
Returns the producer of the module.- Specified by:
getProducer
in interfaceModule
- Returns:
- the producer.
- See Also:
Module.getProducer()
-
setProducer
protected void setProducer(String producer)
Defines the producer of the module.- Parameters:
producer
- the producer.
-
getRequiredModules
public ModuleInfo[] getRequiredModules()
Returns a copy of the required modules array. This array contains all description of the modules that need to be present to make this module work.- Specified by:
getRequiredModules
in interfaceModule
- Returns:
- an array of all required modules.
- See Also:
Module.getRequiredModules()
-
getOptionalModules
public ModuleInfo[] getOptionalModules()
Returns a copy of the required modules array. This array contains all description of the optional modules that may improve the modules functonality.- Specified by:
getOptionalModules
in interfaceModule
- Returns:
- an array of all required modules.
- See Also:
Module.getRequiredModules()
-
setRequiredModules
protected void setRequiredModules(ModuleInfo[] requiredModules)
Defines the required module descriptions for this module.- Parameters:
requiredModules
- the required modules.
-
setOptionalModules
public void setOptionalModules(ModuleInfo[] optionalModules)
Defines the optional module descriptions for this module.- Parameters:
optionalModules
- the optional modules.
-
toString
public String toString()
Returns a string representation of this module.- Overrides:
toString
in classDefaultModuleInfo
- Returns:
- the string representation of this module for debugging purposes.
- See Also:
Object.toString()
-
isClassLoadable
protected static boolean isClassLoadable(String name, Class<?> context)
Tries to load a class to indirectly check for the existence of a certain library.- Parameters:
name
- the name of the library class.context
- the context class to get a classloader from.- Returns:
- true, if the class could be loaded, false otherwise.
-
configure
public void configure(SubSystem subSystem)
Configures the module by loading the configuration properties and adding them to the package configuration.
-
performExternalInitialize
protected void performExternalInitialize(String classname) throws ModuleInitializeException
Deprecated.Use the method that provides a class-context instead.Tries to load an module initializer and uses this initializer to initialize the module.- Parameters:
classname
- the class name of the initializer.- Throws:
ModuleInitializeException
- if an error occures
-
performExternalInitialize
protected void performExternalInitialize(String classname, Class<?> context) throws ModuleInitializeException
Executes an weakly referenced external initializer. The initializer will be loaded using reflection and will be executed once. If the initializing fails with any exception, the module will become unavailable.- Parameters:
classname
- the classname of theModuleInitializer
implementationcontext
- the class-loader context from where to load the module's classes.- Throws:
ModuleInitializeException
- if an error occured or the initializer could not be found.
-
getSubSystem
public String getSubSystem()
Returns the modules subsystem. If this module is not part of an subsystem then return the modules name, but never null.- Specified by:
getSubSystem
in interfaceModule
- Returns:
- the name of the subsystem.
-
setSubSystem
protected void setSubSystem(String name)
Defines the subsystem name for this module. If no sub-system name is set, the sub-system defaults to the module's name.- Parameters:
name
- the new name of the subsystem.
-
-