autohit.call.modules
Class Module

java.lang.Object
  extended byautohit.call.modules.Module
Direct Known Subclasses:
MIMEMessageModule, SimpleHttpModule, SimpleScannerModule, SimpleSmtpModule, StopwatchModule, TextReaderModule, TextWriterModule, TolerantSmtpModule

public abstract class Module
extends java.lang.Object

The abstract base class for modules. Every module must implement this.

An implemented module needs to complete the following abstract methods: execute_chain - run a named method.
instantiation_chain() - called at module instantiation
free_chain() - called at module destruction

All protected methods are helpers for the execute.

Modules are not allowed to have methods called "name"

Version:
1.0 Version History EPG - Initial - 14Jun03
EPG - make SC visible - 3 Sep03
Author:
Erich P. Gatejen

Field Summary
protected  java.lang.String myName
           
protected  VMCore visCore
           
protected  AutohitLogInjectorWrapper visLogger
           
protected  SystemContext visSC
           
protected  Universe visUniverse
           
 
Constructor Summary
Module()
           
 
Method Summary
protected  CallException buildException(java.lang.String message, int code)
          Build a call exception with our formatting
protected  CallException buildException(java.lang.String message, int code, java.lang.Throwable iec)
          Build a call exception with our formatting - chained
protected  void debug(java.lang.String msg)
          Local method for logging debug information
protected  java.lang.String desired(java.lang.String param, java.lang.String method)
          Desired parameter.
protected  java.lang.Object desiredType(java.lang.String param, java.lang.Class type, java.lang.String method)
          Desired parameter.
protected  void error(java.lang.String msg)
          Local method for logging an error
protected  void errorparam(java.lang.String missing, java.lang.String method)
          Local method for logging an error for a missing param.
abstract  java.lang.Object execute_chain(java.lang.String name)
          Execute a named method.
 java.lang.String execute(java.lang.String methodName)
          Execute a method
protected  void fault(java.lang.String message)
          Cause a fault
protected  void fault(java.lang.String message, java.lang.Throwable t)
          Cause a fault with CHAIN
protected abstract  void free_chain()
          Allow the subclass a chance to cleanup on free.
 void free()
          Remove an instance
protected  java.lang.Object getParam(java.lang.String name)
          Get a parameter
protected  java.lang.Object getPersist(java.lang.String name)
          Get a persisted object
 void instance(VMCore core, Universe uni, AutohitLogInjectorWrapper logger, SystemContext sctx)
          Instantiate
protected abstract  java.lang.String instantiation_chain()
          Allow the subclass a chance to initialize.
protected  boolean isDebugging()
          report if we are debugging (as an accellerator)
protected  void log(java.lang.String msg)
          Local method for logging an event
protected  java.lang.String optional(java.lang.String param)
          Optional parameter.
protected  java.lang.Object optionalType(java.lang.String param, java.lang.Class type)
          Optional parameter.
protected  java.lang.String required(java.lang.String param, java.lang.String method)
          Required parameter.
protected  java.lang.Object requiredType(java.lang.String param, java.lang.Class type, java.lang.String method)
          Required parameter.
protected  void warning(java.lang.String msg)
          Local method for logging an warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visCore

protected VMCore visCore

visUniverse

protected Universe visUniverse

visLogger

protected AutohitLogInjectorWrapper visLogger

myName

protected java.lang.String myName

visSC

protected SystemContext visSC
Constructor Detail

Module

public Module()
Method Detail

instance

public void instance(VMCore core,
                     Universe uni,
                     AutohitLogInjectorWrapper logger,
                     SystemContext sctx)
              throws CallException
Instantiate

Parameters:
core - is a reference to the environment core
uni - is the default universe
logger - is the default logger
Throws:
CallException
See Also:
VMCore, Universe, AutohitLogInjectorWrapper

free

public void free()
          throws CallException
Remove an instance

Throws:
CallException

execute

public java.lang.String execute(java.lang.String methodName)
                         throws CallException
Execute a method

Parameters:
methodName - the name of the method
Returns:
any resultant object String
Throws:
CallException

isDebugging

protected boolean isDebugging()
report if we are debugging (as an accellerator)

Returns:
parameter value or null if not found

getParam

protected java.lang.Object getParam(java.lang.String name)
Get a parameter

Parameters:
name - of the parameter
Returns:
parameter value or null if not found

getPersist

protected java.lang.Object getPersist(java.lang.String name)
Get a persisted object

Parameters:
name - of the object in the persist
Returns:
parameter value or null if not found

log

protected void log(java.lang.String msg)
Local method for logging an event

Parameters:
msg - event message

error

protected void error(java.lang.String msg)
Local method for logging an error

Parameters:
msg - event message

errorparam

protected void errorparam(java.lang.String missing,
                          java.lang.String method)
Local method for logging an error for a missing param.

Parameters:
missing - name of paramater missing
method - name of method called

warning

protected void warning(java.lang.String msg)
Local method for logging an warning

Parameters:
msg - event message

debug

protected void debug(java.lang.String msg)
Local method for logging debug information

Parameters:
msg - event message

buildException

protected CallException buildException(java.lang.String message,
                                       int code)
Build a call exception with our formatting

Parameters:
message - text of the message
code - the autohit error code (also available in CallException)
Returns:
a CallException
See Also:
CallException, AutohitErrorCodes

fault

protected void fault(java.lang.String message)
              throws CallException
Cause a fault

Parameters:
message - text of the message
Throws:
a - CallException
CallException
See Also:
CallException

fault

protected void fault(java.lang.String message,
                     java.lang.Throwable t)
              throws CallException
Cause a fault with CHAIN

Parameters:
message - text of the message
Throws:
a - CallException
CallException
See Also:
CallException

buildException

protected CallException buildException(java.lang.String message,
                                       int code,
                                       java.lang.Throwable iec)
Build a call exception with our formatting - chained

Parameters:
message - text of the message
code - the autohit error code (also available in CallException)
iec - initiating exception
Returns:
a CallException
See Also:
CallException, AutohitErrorCodes

required

protected java.lang.String required(java.lang.String param,
                                    java.lang.String method)
                             throws CallException
Required parameter. This one requires the parameter to be a string. If it is not present or is not a String, it is a serious fault

Parameters:
param - parameter name
method - method being called. Used for error reporting.
Returns:
String with the parameter value
Throws:
CallException

requiredType

protected java.lang.Object requiredType(java.lang.String param,
                                        java.lang.Class type,
                                        java.lang.String method)
                                 throws CallException
Required parameter. This one requires the parameter to be of the type specified. If it is not present or is not the type, it is a serious fault

Parameters:
param - parameter name
type - the class of the type required
method - method being called. Used for error reporting.
Returns:
String with the parameter value
Throws:
CallException

desired

protected java.lang.String desired(java.lang.String param,
                                   java.lang.String method)
Desired parameter. If it is not present, it is an error message

Parameters:
param - parameter name
method - method being called. Used for error reporting.
Returns:
String with the parameter value or null if it is not present

desiredType

protected java.lang.Object desiredType(java.lang.String param,
                                       java.lang.Class type,
                                       java.lang.String method)
Desired parameter. If it is not present, it is an error message.

Parameters:
param - parameter name
type - the class of the type desired
method - method being called. Used for error reporting.
Returns:
Object with the parameter value or null if it is not present or the wrong type.

optional

protected java.lang.String optional(java.lang.String param)
Optional parameter. If it is not present, nothing happens. It expects a String. If result is something other than a String, it will return a null.

Parameters:
param - parameter name
Returns:
String with the parameter value or null if it is not present

optionalType

protected java.lang.Object optionalType(java.lang.String param,
                                        java.lang.Class type)
Optional parameter. If it is not present, nothing happens. It expects the type specified. If result is something other than that type, it will return a null.

Parameters:
param - parameter name
type - the class of the type optional
Returns:
Object with the parameter value or null if it is not present

execute_chain

public abstract java.lang.Object execute_chain(java.lang.String name)
                                        throws CallException
Execute a named method. You must implement this method. You can call any of the helpers for data and services. The returned object better be a string (for now). YOU MUST RETURN SOMETHING--and not null! If you don't, there will be an exception up the chain.

Parameters:
name - name of the method
Throws:
CallException
See Also:
NOPair

instantiation_chain

protected abstract java.lang.String instantiation_chain()
                                                 throws CallException
Allow the subclass a chance to initialize. At a minium, an implementor should create an empty method.

Returns:
the name of the module
Throws:
CallException

free_chain

protected abstract void free_chain()
                            throws CallException
Allow the subclass a chance to cleanup on free. At a minium, an implementor should create an empty method.

Throws:
CallException


Test.