org.yawlfoundation.yawl.resourcing.codelets
Class AbstractCodelet

java.lang.Object
  extended by org.yawlfoundation.yawl.resourcing.codelets.AbstractCodelet
Direct Known Subclasses:
ExampleCodelet, RandomWait, ShellExecution, SupervisorInfo, TaskCompleterInfo, XQueryEvaluator

public abstract class AbstractCodelet
extends Object

The base class of all codelets.

Author:
Michael Adams
Created/Last Date:
17/06/2008

Field Summary
protected  String _description
           
protected static String XSD_NAMESPACE
           
 
Constructor Summary
protected AbstractCodelet()
           
protected AbstractCodelet(String desc)
           
 
Method Summary
 void cancel()
          This method is called when the work item running this codelet is cancelled.
abstract  org.jdom.Element execute(org.jdom.Element inData, List<YParameter> inParams, List<YParameter> outParams)
          This method must be implemented to do the work of the codelet.
 String getCanonicalClassName()
           
 String getClassName()
           
 String getDescription()
           
protected  YParameter getInputParameter(String paramName)
           
protected  org.jdom.Element getOutputData()
           
protected  YParameter getOutputParameter(String paramName)
           
protected  Object getParameterValue(String varName)
          Converts the string representation of a parameter value to its specified data type, for the most frequent data types.
 boolean getPersist()
           
 List<YParameter> getRequiredParams()
          This method is called when an external entity (such as the YAWL editor) requests the list of parameters required by the codelet.
 String getRequiredParamsToXML()
           
protected  String getValue(String varName)
          Gets the value of a parameter
 WorkItemRecord getWorkItem()
           
 void init()
          This method is called when a codelet first starts.
 void resume()
          This method is called when the codelet is resumed after a server shutdown.
 void setDescription(String desc)
           
protected  void setInputs(org.jdom.Element inData, List<YParameter> inParams, List<YParameter> outParams)
           
protected  void setParameterValue(String varName, String value)
          Adds a new value to an output parameter, and creates the parameter if it doesn't already exist
protected  void setPersist(boolean persist)
           
 void setWorkItem(WorkItemRecord wir)
           
 void shutdown()
          This method is called when the server is shutting down.
 String toXML()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_description

protected String _description

XSD_NAMESPACE

protected static final String XSD_NAMESPACE
See Also:
Constant Field Values
Constructor Detail

AbstractCodelet

protected AbstractCodelet()

AbstractCodelet

protected AbstractCodelet(String desc)
Method Detail

getDescription

public String getDescription()

setDescription

public void setDescription(String desc)

getWorkItem

public WorkItemRecord getWorkItem()

setWorkItem

public void setWorkItem(WorkItemRecord wir)

getPersist

public boolean getPersist()

setPersist

protected void setPersist(boolean persist)

setInputs

protected void setInputs(org.jdom.Element inData,
                         List<YParameter> inParams,
                         List<YParameter> outParams)

getParameterValue

protected Object getParameterValue(String varName)
                            throws CodeletExecutionException
Converts the string representation of a parameter value to its specified data type, for the most frequent data types. Implementers may override this method to handle other data types if required.

Parameters:
varName - the name of the parameter
Returns:
the appropriately typed value
Throws:
CodeletExecutionException - if the string value can't be converted to the specified type.

setParameterValue

protected void setParameterValue(String varName,
                                 String value)
Adds a new value to an output parameter, and creates the parameter if it doesn't already exist

Parameters:
varName - the name of the parameter
value - the value to assign to it

getOutputData

protected org.jdom.Element getOutputData()

getInputParameter

protected YParameter getInputParameter(String paramName)
                                throws CodeletExecutionException
Throws:
CodeletExecutionException

getOutputParameter

protected YParameter getOutputParameter(String paramName)
                                 throws CodeletExecutionException
Throws:
CodeletExecutionException

getValue

protected String getValue(String varName)
                   throws CodeletExecutionException
Gets the value of a parameter

Parameters:
varName - the name of the parameter
Returns:
its value
Throws:
CodeletExecutionException - if the parameter doesn't exist in the input data

getClassName

public String getClassName()

getCanonicalClassName

public String getCanonicalClassName()

toXML

public String toXML()

getRequiredParamsToXML

public String getRequiredParamsToXML()

init

public void init()
This method is called when a codelet first starts. Override to include any initialisations required.


shutdown

public void shutdown()
This method is called when the server is shutting down. Override to include any state saving required.


resume

public void resume()
This method is called when the codelet is resumed after a server shutdown. Override to include any state restoring required.


cancel

public void cancel()
This method is called when the work item running this codelet is cancelled. Override to cancel the codelet as required.


getRequiredParams

public List<YParameter> getRequiredParams()
This method is called when an external entity (such as the YAWL editor) requests the list of parameters required by the codelet. Override to populate the list. Each parameter should include a name, data type and description as a minimum.

Returns:
the List of parameters required by the codelet.

execute

public abstract org.jdom.Element execute(org.jdom.Element inData,
                                         List<YParameter> inParams,
                                         List<YParameter> outParams)
                                  throws CodeletExecutionException
This method must be implemented to do the work of the codelet.

Parameters:
inData - the work item's input data
inParams - the work item's input parameters
outParams - the work item's output parameters
Returns:
a JDOM Element containing the output data generated by this method
Throws:
CodeletExecutionException - if there's any problem getting the required input data, composing the required output data, or performing the execution.


Copyright © 2004-2012 The YAWL Foundation.