wrapper
Class CPAMMegamodule

java.lang.Object
  |
  +--wrapper.CPAMMegamodule

public abstract class CPAMMegamodule
extends java.lang.Object


Field Summary
private  java.util.Map connections
          Maps connection ids to connection objects.
private  ParamValueTable defaultParams
          Table of all the parameters in the megamodule and their default values.
(package private) static int noCon
          Number of possible connections per megamodule.
(package private) static int noInv
          Number of possible invocation per connection
(package private)  java.lang.String paramType
          Kind of parameters this megamodule accepts (String or Gentype or ....)
private  java.util.Random random
           
 
Constructor Summary
CPAMMegamodule(java.lang.String paramType)
           
 
Method Summary
protected  boolean abortExecution(Invocation invocationObject, java.lang.String methodname)
          Abort the invocation.
 void addParam(java.lang.String paramname, java.lang.Object paramvalue)
          Adds a name value pair to the list of known paramaters of a megamodule.
(package private)  void connectionTerminated(java.lang.Integer connectionId)
           
(package private)  java.lang.Integer createConnection()
          Creates a new connection object and its connection id.
protected  void createParameters()
          Sets up the table with the parameter names and default values for this megamodule.
protected abstract  boolean dispatchInvocation(CPAMWrapperCallbacks invocationObject, java.lang.String methodname)
          Executes an invocation.
(package private)  Connection getConnection(java.lang.Integer connectionId)
           
(package private)  Invocation getInvocation(java.lang.Integer invocationId)
           
protected  boolean makeEstimate(Estimates estimates, java.lang.String methodname, ParamValueTableReader clientsettings)
          Make estimates.
protected  void updateExecutionStatus(CPAMWrapperCallbacks invocationObject, java.lang.String methodname)
          If new progress information exists for the invocation given by invocationObject or if new result values exist that influence the status of this invocation, report them now.
protected  void updateResult(java.lang.String paramname, CPAMWrapperCallbacks invocationObject, java.lang.String methodname)
          If new results for the parameter with the name paramname exist that have not yet been reported back to the wrapper, do it now.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

noInv

static final int noInv
Number of possible invocation per connection

noCon

static final int noCon
Number of possible connections per megamodule.

The following condition must be fulfilled:
noInv * noCon + noCon < MAX int


defaultParams

private ParamValueTable defaultParams
Table of all the parameters in the megamodule and their default values.

paramType

final java.lang.String paramType
Kind of parameters this megamodule accepts (String or Gentype or ....)

connections

private java.util.Map connections
Maps connection ids to connection objects.

random

private java.util.Random random
Constructor Detail

CPAMMegamodule

public CPAMMegamodule(java.lang.String paramType)
Method Detail

createParameters

protected void createParameters()
Sets up the table with the parameter names and default values for this megamodule. This method should be overwritten when applying the wrapper template by subclassing.

Use addParam(String name, Object value) to create the name value pairs. The names and the types of the values have to correspond to the names and types specified in the repository. In case of duplicate names or invalid types the method addParam throws ParameterNameException and ParameterTypeException.


addParam

public final void addParam(java.lang.String paramname,
                           java.lang.Object paramvalue)
Adds a name value pair to the list of known paramaters of a megamodule. This list should be consistent with the CHAIMS repository. Only use this method within createParameters. The values are default settings that are used by GETPARAM and INVOKE when no client specific or invocation specific settings exist.
Throws:
ParameterNameException - the parameter already exists or the parameter is not in the repository
ParameterTypeException - the type of the parameter is not okay

makeEstimate

protected boolean makeEstimate(Estimates estimates,
                               java.lang.String methodname,
                               ParamValueTableReader clientsettings)
                        throws MethodNameException
Make estimates. This method should be overwritten when applying the wrapper template to a megamodule that knows how to make estimates.

Return true (for estimates being available). The datastructure 'estimates' contains the fields timeRequired, feeRequired, datavolumeRequired, timeProvided , feeProvided, datavolumeProvided, timeValue, feeValue, datavolumeValue, timeAccuracy, feeAccuracy, datavolumeAccuracy. The ParamValueTable 'clientsettings' contains the client-specific parameter settings. The values can be read with clientsettings.get("parametername"). In case of an unknown methodname, throw an exception of type MethodNameException.


dispatchInvocation

protected abstract boolean dispatchInvocation(CPAMWrapperCallbacks invocationObject,
                                              java.lang.String methodname)
Executes an invocation. Makes synchronous invocation of (legacy) computational code. This method must be overwritten when using the wrapper template.

Methodname is the name of the method invoked according to the CHAIMS repository. In case of an unknown methodname, throw an exception of type MethodNameException. InvocationObject gives the reference to the object holding invocation specific parameter settings, results, progress information and status information for the invocation.

The method must return true upon successful completion of the computation, or false in case of errors that result in being unable to complete all results or in case of an abort. Before returning with true all the final results have to be stored in the invocationObject.

Methods to use (@see also interface CPAMWrapperCallbacks): Method for getting invocation parameters: getParam Method for storing final results: updateParam Methods for storing progressive results and progress information: updateParam, updateInvocationProgress Other useful methods and fields: containsParam, getInvocationId, getInvocationParams Alternative for using getParam: getInvocationParams.get Alternative for storing progressive results and progress information within this method: overwrite the methods getInvocationProgress, getResultProgress, getResultValue ????


abortExecution

protected boolean abortExecution(Invocation invocationObject,
                                 java.lang.String methodname)
Abort the invocation. This method may be overwritten if the computational code can be aborted. The executing invocation given by invocationObject should be aborted. If an immediate abort is possible return true (the invocation referenced by invocationObject will no longer be available and its references should not be used anymore). Otherwise return false (in this case results and status can still be written back in the usual way). If a deferred abort is possible, return false for this method, and return false to dispatchInvocation once the computation has aborted and no longer needs to reference invocationObject. Methodname gives the name of the method invoked by this invocation. It is optional to overwrite this method.

updateResult

protected void updateResult(java.lang.String paramname,
                            CPAMWrapperCallbacks invocationObject,
                            java.lang.String methodname)
If new results for the parameter with the name paramname exist that have not yet been reported back to the wrapper, do it now. For reporting results use invocationObject.updateParam(...). It is optional to overwrite this method.

updateExecutionStatus

protected void updateExecutionStatus(CPAMWrapperCallbacks invocationObject,
                                     java.lang.String methodname)
If new progress information exists for the invocation given by invocationObject or if new result values exist that influence the status of this invocation, report them now. For reporting results use invocationObject.updateParam(...). For reporting invocation progress use invocationObject.updateInvocationProgress(...).

getInvocation

final Invocation getInvocation(java.lang.Integer invocationId)

getConnection

final Connection getConnection(java.lang.Integer connectionId)

connectionTerminated

final void connectionTerminated(java.lang.Integer connectionId)

createConnection

final java.lang.Integer createConnection()
Creates a new connection object and its connection id. The connection id is used to reference this connection and can also be transmitted to a client beyond the barrier of autonomy. Puts the connection object with its connection id into the table 'connections' and returns the connection id.