org.mmbase.module
Class Module

java.lang.Object
  extended byorg.mmbase.util.functions.FunctionProvider
      extended byorg.mmbase.module.Module
Direct Known Subclasses:
AbstractSendMail, ProcessorModule, ReloadableModule, TransactionHandler

public abstract class Module
extends FunctionProvider

An MMBase Module is an extension of this class, which is configured by an XML in the <mmbase config dir >/modules directory. All XML's (which are defined 'active') in this directory are automaticly loaded, and all found 'Module's are then initialized. There are several Modules which are more or less compulsary in MMBase, like the 'mmbaseroot' module, the actual core of MMBase implemented by MMBase, and the 'jdbc' module.

Version:
$Id: Module.java,v 1.77 2006/05/22 16:26:39 michiel Exp $
Author:
Rico Jansen, Rob Vermeulen (securitypart), Pierre van Rooden

Field Summary
protected  Function getMaintainerFunction
          This function returns the Module's maintainer as a String.
protected  Function getVersionFunction
          This function returns the Module's version number as an Integer.
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
Module()
           
 
Method Summary
 String getInitParameter(String key)
          Gets an init-parameter key-value pair
 Hashtable getInitParameters()
          Gets own modules properties
 String getMaintainer()
           
static Module getModule(String name)
          Retrieves a reference to a Module.
static Module getModule(String name, boolean startOnLoad)
          Retrieves a reference to a Module.
 String getModuleInfo()
          provide some info on the module
static ResourceLoader getModuleLoader()
           
static ModuleReader getModuleReader(String moduleName)
           
static Iterator getModules()
          Returns an iterator of all the modules that are currently active.
 String getName()
          Returns the name of the module
protected  Hashtable getProperties(String propertytable)
          Returns the properties to the subclass.
protected  String getProperty(String name, String var)
          Returns one propertyvalue to the subclass.
 int getVersion()
           
 boolean hasStarted()
          Returns whether the module has started (has been initialized or is in its initialization fase).
 void init()
          Initializes the module.
 void maintainance()
          maintainance call called by the admin module every x seconds.
 void onload()
          prepares the module when loaded.
 void setInitParameter(String key, String value)
          Sets an init-parameter key-value pair
 void setMaintainer(String m)
           
 void setName(String name)
           
 void setVersion(int v)
           
protected  void shutdown()
          Shuts down the module.
static void shutdownModules()
          Calls shutdown of all registered modules.
 void startModule()
          Starts the module.
static void startModules()
           
 Hashtable state()
          state, returns the state hashtable that is/can be used to debug.
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

getVersionFunction

protected Function getVersionFunction
This function returns the Module's version number as an Integer. It takes no parameters. This function can be called through the function framework.

Since:
MMBase-1.8

getMaintainerFunction

protected Function getMaintainerFunction
This function returns the Module's maintainer as a String. It takes no parameters. This function can be called through the function framework.

Since:
MMBase-1.8
Constructor Detail

Module

public Module()
Method Detail

setName

public final void setName(String name)

getModuleLoader

public static ResourceLoader getModuleLoader()
Since:
MMBase-1.8

getModuleReader

public static ModuleReader getModuleReader(String moduleName)
Since:
MMBase-1.8

startModule

public final void startModule()
Starts the module. This module calls the init() of a module exactly once. In other words, once the init() is called, it does not call it again. This method is final and cannot be overridden. It is used to safely initialize modules during startup, and allows other modules to force the 'startup' of another module without risk.


hasStarted

public final boolean hasStarted()
Returns whether the module has started (has been initialized or is in its initialization fase).


init

public void init()
Initializes the module. Init must be overridden to read the environment variables it needs.
This method is called by startModule(), which makes sure it is not called more than once. You should not call init() directly, call startModule() instead.


onload

public void onload()
prepares the module when loaded. Onload must be overridden to execute methods that need to be performed when the module is loaded but before any other modules are initailized.
This method is called by startModules(). You should not call onload() directly.

Warning: Scope will be changed to:
protected

shutdown

protected void shutdown()
Shuts down the module. This method is called by shutdownModules.

Since:
MMBase-1.6.2

state

public Hashtable state()
state, returns the state hashtable that is/can be used to debug. Should be overridden when live state should be done.


setInitParameter

public void setInitParameter(String key,
                             String value)
Sets an init-parameter key-value pair


getInitParameter

public String getInitParameter(String key)
Gets an init-parameter key-value pair


getProperties

protected Hashtable getProperties(String propertytable)
Returns the properties to the subclass.


getProperty

protected String getProperty(String name,
                             String var)
Returns one propertyvalue to the subclass.


getInitParameters

public Hashtable getInitParameters()
Gets own modules properties


getModules

public static final Iterator getModules()
Returns an iterator of all the modules that are currently active. This function null if no attempt has the modules have (not) yet been to loaded. Unlike getModule(java.lang.String), this method does not automatically load modules if this hadn't occurred yet.

Returns:
an Iterator with all active modules

getName

public final String getName()
Returns the name of the module

Returns:
the module name

getModuleInfo

public String getModuleInfo()
provide some info on the module


maintainance

public void maintainance()
maintainance call called by the admin module every x seconds.


shutdownModules

public static final void shutdownModules()
Calls shutdown of all registered modules.

Since:
MMBase-1.6.2

startModules

public static final void startModules()

getModule

public static Module getModule(String name)
Retrieves a reference to a Module. This call does not ensure that the requested module has been initialized.

Parameters:
name - the name of the module to retrieve
Returns:
a refernce to a Module, or null if the module does not exist or is inactive.

getModule

public static Module getModule(String name,
                               boolean startOnLoad)
Retrieves a reference to a Module. If you set the startOnLoad to true, this call ensures that the requested module has been initialized by calling the startModule() method. This is needed if you need to call Module methods from the init() of another module.

Parameters:
name - the name of the module to retrieve
startOnLoad - if true, the code makes sure the module has been started
Returns:
a reference to a Module, or null if the module does not exist or is inactive.

getMaintainer

public String getMaintainer()

setMaintainer

public void setMaintainer(String m)

setVersion

public void setVersion(int v)

getVersion

public int getVersion()


MMBase build 1.8.1.20060716