public abstract class AbstractModule extends java.lang.Object implements Module
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoStart |
protected boolean |
isInitialized |
protected boolean |
isRunning |
protected org.apache.commons.logging.Log |
logging
A Log implementation that is set in the require Logging method.
|
protected LoggingModule |
loggingModule
A logging module that is set in the requireLogging method.
|
protected ModuleManager |
moduleManager
The module manager that handles this module.
|
| Constructor and Description |
|---|
AbstractModule() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<Module> |
getDependencies(ModuleManager manager)
Returns all the modules this module depends on.
|
void |
init(ModuleManager manager,
java.util.HashMap<java.lang.String,java.lang.Object> settings)
Initialises the module.
|
boolean |
isInitialized()
Checks if the module is initialised.
|
boolean |
isRunning()
Checks if the module is running.
|
protected java.util.Collection<Module> |
requireLogging(ModuleManager manager,
java.util.Collection<Module> dependencies)
A helper method that adds logging into dependencies.
|
void |
start(ModuleManager manager)
Starts the module.
|
void |
stop(ModuleManager manager)
Stops the module.
|
java.lang.String |
toString()
Makes a string representation of this module using ModuleManager.moduleToString.
|
protected boolean isInitialized
protected boolean isRunning
protected boolean autoStart
protected LoggingModule loggingModule
protected org.apache.commons.logging.Log logging
protected ModuleManager moduleManager
public void init(ModuleManager manager, java.util.HashMap<java.lang.String,java.lang.Object> settings) throws ModuleException
ModuleInitialises the module. After constructor, this is the first method called in the life cycle of a module. It should not perform anything time consuming or anything with notable outside side effects. It should only read the parameters and initialise the module so that it can later be started. Note that a module being initialised doesn't mean that it necessarily will ever be started.
A ModuleException may be thrown if something vital is missing from the parameters or they are not sensible. In some cases you may not want to throw an exception even if vital initialisation information is missing. If, for example, it is possible that the module is initialised in some other way between the init and the start method calls. A ModuleException may also be thrown at the start method if the module is still not initialised.
init in interface Modulemanager - The module manager handling this module. You may keep a
reference to it if needed.ModuleExceptionpublic boolean isInitialized()
ModuleisInitialized in interface Modulepublic boolean isRunning()
Modulepublic java.util.Collection<Module> getDependencies(ModuleManager manager) throws ModuleException
ModulegetDependencies in interface Modulemanager - The module manager handling this module.ModuleExceptionprotected java.util.Collection<Module> requireLogging(ModuleManager manager, java.util.Collection<Module> dependencies) throws ModuleException
A helper method that adds logging into dependencies. Typically you will call this in your overridden getDependencies method. After that you can use the logging facilities of the logging instance variable. AbstractModule does not automatically require logging, but it provides some functionality for the typical case where you do need logging.
Note that typically modules are not usable before they have been started, and the logging module may only have been started just before calling start of this module. As such, the module would be unusable before that, in particular in init and getDependencies methods. However, logging modules should be built in such a way that they are usable immediately after having been initialised. In other words, you can assume that you can use it as soon as you have a reference to it. You may also call requireLogging already in init method to have logging available there. You should still also add it to the dependencies later in getDependencies.
manager - dependencies - ModuleExceptionpublic void start(ModuleManager manager) throws ModuleException
Modulestart in interface Modulemanager - The module manager handling this module.ModuleExceptionpublic void stop(ModuleManager manager)
Modulepublic java.lang.String toString()
toString in class java.lang.ObjectCopyright 2004-2015 Wandora Team