org.iges.anagram
Class AbstractModule

java.lang.Object
  |
  +--org.iges.anagram.AbstractModule
All Implemented Interfaces:
Module
Direct Known Subclasses:
Catalog, Filter, GradsAnalysisModule, GradsDODSModule, GradsExtracter, GradsImportModule, GradsSubsetter, GradsTaskModule, GradsUpdateModule, GradsUploadModule, Mapper, PrivilegeMgr, Service, Store, Tool

public abstract class AbstractModule
extends java.lang.Object
implements Module

Provides default implementations of most of the Module interface, plus some convenience methods for logging and throwing exceptions.

The only methods that remain to be implemented by subclasses are getModuleID() and configure(Setting setting).


Field Summary
protected  Log log
          Reference to the log module
protected  java.lang.String moduleName
          Complete name of this module, including parents
protected  Module parent
          Parent of this module
protected  Server server
          Reference to the top-level module
 
Constructor Summary
AbstractModule()
           
 
Method Summary
protected  void configModule(Module module, Setting parent)
          Convenience method - extracts the appropriate sub-setting from the parent setting, and uses it to configure the module given
abstract  void configure(Setting setting)
          Configures the module according to the settings provided.
protected  boolean debug()
          Convenience method - returns true if debugging output is enabled for this module.
protected  void debug(java.lang.String msg)
          Convenience method - sends a debug message to the logger
protected  void error(java.lang.String msg)
          Convenience method - sends an error message to the logger
protected  void fail(java.lang.String msg)
          Convenience method - equivalent to throwing a ModuleException
protected  void fail(java.lang.String clientMsg, java.lang.String serverMsg)
          Convenience method - equivalent to throwing a ModuleException
protected  void fail(java.lang.String msg, java.lang.Throwable cause)
          Convenience method - equivalent to throwing a ModuleException
abstract  java.lang.String getModuleID()
          Returns an ID for this module.
 java.lang.String getModuleName()
          Returns the full name of this module, including parent modules
protected  void info(java.lang.String msg)
          Convenience method - sends an info message to the logger
 void init(Server server, Module parent)
          Saves references to the server, log module, and parent module, and constructs the complete module name.
 java.lang.String toString()
          Shuts down the module.
protected  boolean verbose()
          Convenience method - returns true if verbose output is enabled for this module.
protected  void verbose(java.lang.String msg)
          Convenience method - sends a verbose message to the logger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected Module parent
Parent of this module


moduleName

protected java.lang.String moduleName
Complete name of this module, including parents


server

protected Server server
Reference to the top-level module


log

protected Log log
Reference to the log module

Constructor Detail

AbstractModule

public AbstractModule()
Method Detail

getModuleName

public java.lang.String getModuleName()
Returns the full name of this module, including parent modules

Specified by:
getModuleName in interface Module

getModuleID

public abstract java.lang.String getModuleID()
Description copied from interface: Module
Returns an ID for this module. This ID should be a legal XML tag name. It has two uses: as a tag name in the server's configuration file, and as the final element of the complete module name.

Specified by:
getModuleID in interface Module

configure

public abstract void configure(Setting setting)
                        throws ConfigException
Configures the module according to the settings provided. The server supports dynamic reconfiguration. Thus this method may be called at any time in the life of the module. If the module cannot be reconfigured, it should throw an exception.

Specified by:
configure in interface Module
Throws:
SettingException - if invalid settings are provided; if this module has previously been configured, and does not support dynamic reconfiguration; or if the destroy() method has already been called
ConfigException - If the module is unable to operate using the settings provided. This will halt the server's operation, and thus should only be thrown if there is no reasonable default that can be used in place of a missing or invalid setting.

configModule

protected void configModule(Module module,
                            Setting parent)
                     throws ConfigException
Convenience method - extracts the appropriate sub-setting from the parent setting, and uses it to configure the module given

Parameters:
module - Module to be configured
ConfigException

init

public void init(Server server,
                 Module parent)
Saves references to the server, log module, and parent module, and constructs the complete module name. Subclasses which override this method should call super.init().

Specified by:
init in interface Module

debug

protected final boolean debug()
Convenience method - returns true if debugging output is enabled for this module. All debug messages should be enclosed in a conditional that tests this function. Otherwise, even when debugging is off, the server will be forced to construct all the debug message strings, resulting in a huge number of unnecessary String object creations.


verbose

protected final boolean verbose()
Convenience method - returns true if verbose output is enabled for this module. All verbose messages should be enclosed in a conditional that tests this function. Otherwise, even when verbose output is off, the server will be forced to construct all the verbose message strings, resulting in a huge number of unnecessary String object creations.


debug

protected final void debug(java.lang.String msg)
Convenience method - sends a debug message to the logger


verbose

protected final void verbose(java.lang.String msg)
Convenience method - sends a verbose message to the logger


info

protected final void info(java.lang.String msg)
Convenience method - sends an info message to the logger


error

protected final void error(java.lang.String msg)
Convenience method - sends an error message to the logger


fail

protected final void fail(java.lang.String msg)
                   throws ModuleException
Convenience method - equivalent to throwing a ModuleException

ModuleException

fail

protected final void fail(java.lang.String msg,
                          java.lang.Throwable cause)
                   throws ModuleException
Convenience method - equivalent to throwing a ModuleException

ModuleException

fail

protected final void fail(java.lang.String clientMsg,
                          java.lang.String serverMsg)
                   throws ModuleException
Convenience method - equivalent to throwing a ModuleException

ModuleException

toString

public java.lang.String toString()
Shuts down the module. This method should put the module in a state such that it is ready to be garbage collected. public void destroy();

Overrides:
toString in class java.lang.Object