public abstract class ActionImpl extends java.lang.Object implements Action
To implement a subclass of ActionImpl:
Action.configure method with action-specific
configuration. This will typically also involve defining the
corresponding action configuration class, which carries the
information necessary to configure the action.
Action.initialize method with
action-specific parameter initialization. You can use the methods
storeRequiredParameter and
storeOptionalParameter in this class to validate and
store parameter Expressions for later evaluation or retrieval. For
example,
public void initialize(Map pParameters) throws ProcessException { storeRequiredParameter(pParameters, PARAM_PATH, String.class); storeOptionalParameter(pParameters, PARAM_COUNT, Integer.class); }
executeAction method defined in this
class to execute the action in a single process execution context.
You can use the getParameterValue method to evaluate
the parameter expressions. For example,
protected void executeAction(ProcessExecutionContext pContext) throws ProcessException { // evaluate parameter expressions (note: count may be null) String path = (String) getParameterValue(PARAM_PATH, pContext); Integer count = (Integer) getParameterValue(PARAM_COUNT, pContext); // execute the action using these parameter values ... }
getActionName method
defined in this class to return the name of the action. The action
name is used in the toString method. By default, the
name of the Action class is used as the action name.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
| Constructor and Description |
|---|
ActionImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(java.lang.Object pConfiguration)
Configures the action using the given configuration object.
|
void |
execute(ProcessExecutionContext pContext)
Executes the action in the given process execution context.
|
void |
execute(ProcessExecutionContext[] pContexts)
Executes the action in each of the given process execution
contexts.
|
protected abstract void |
executeAction(ProcessExecutionContext pContext)
Executes this action in the given single process execution
context.
|
java.lang.String |
getActionName()
Returns the default name of the action.
|
protected Expression |
getParameterExpression(java.lang.String pParameterName)
Returns the given parameter Expression.
|
protected java.lang.Object |
getParameterValue(java.lang.String pParameterName,
ProcessExecutionContext pContext)
Evaluates the given parameter Expression in the given context,
and returns the value.
|
void |
initialize(java.util.Map pParameters)
Initializes the action with the given parameters.
|
protected void |
storeOptionalParameter(java.util.Map pParameters,
java.lang.String pParameterName,
java.lang.Class pParameterValueType)
Extracts an Expression with the given parameter name from the
given parameter Map, and stores it for later retrieval.
|
protected void |
storeRequiredMutableParameter(java.util.Map pParameters,
java.lang.String pParameterName)
Extracts a MutableExpression with the given parameter name from
the given parameter Map, and stores it for later retrieval.
|
protected void |
storeRequiredParameter(java.util.Map pParameters,
java.lang.String pParameterName,
java.lang.Class pParameterValueType)
Extracts an Expression with the given parameter name from the
given parameter Map, and stores it for later retrieval.
|
java.lang.String |
toString()
Returns the String representation of the Action.
|
java.lang.String |
toString(java.lang.String pActionName)
Returns the String representation of the Action.
|
protected void storeRequiredParameter(java.util.Map pParameters,
java.lang.String pParameterName,
java.lang.Class pParameterValueType)
throws ProcessException
ProcessException - if no parameter by this name is
found in the map, if the parameter value is not an Expression, or
if the constant Expression has a value which does not match the
given value typeprotected void storeOptionalParameter(java.util.Map pParameters,
java.lang.String pParameterName,
java.lang.Class pParameterValueType)
throws ProcessException
ProcessException - if the parameter value is not an
Expression, or if the constant Expression has a value which does
not match the given value typeprotected void storeRequiredMutableParameter(java.util.Map pParameters,
java.lang.String pParameterName)
throws ProcessException
ProcessException - if no parameter by this name is
found in the map, or if the parameter value is not a
MutableExpressionprotected Expression getParameterExpression(java.lang.String pParameterName)
protected java.lang.Object getParameterValue(java.lang.String pParameterName,
ProcessExecutionContext pContext)
throws ProcessException
storeRequiredParameter or
storeOptionalParameter. If the parameter Expression
is constant, returns the cached constant value. If there is no
Expression stored for this parameter, or if the Expression
evaluates to null, returns null.ProcessException - if the evaluated Expression has a
value which does not match this parameter's value typeprotected abstract void executeAction(ProcessExecutionContext pContext) throws ProcessException
execute methods.ProcessException - if the action can not be executedpublic void configure(java.lang.Object pConfiguration)
throws ProcessException,
java.lang.UnsupportedOperationException
This operation is optional. This default implementation throws an UnsupportedOperationException.
configure in interface ActionProcessException - if the action could not be configured
- for example, because some of the required properties are
missing from the configurationjava.lang.UnsupportedOperationException - if this action is not
configurablepublic void initialize(java.util.Map pParameters)
throws ProcessException
This default implementation does nothing.
initialize in interface ActionProcessException - if the action could not be properly
initialized - for example, if not all of the required parameters
are present in the MapExpressionpublic void execute(ProcessExecutionContext pContext) throws ActionException
This default implementation calls executeAction.
If that throws a ProcessException, this method throws a
corresponding ActionException.
execute in interface ActionActionException - if the action failed when executed in
this context; the process engine will catch the ActionException
and respond based on the value of the action's error response, as
specified in the ActionException itself and/or the action
registry; for example, the engine may ignore the error and
continue, or it may delete the process instance pointed to by the
context and stop executing the process segment in this contextpublic void execute(ProcessExecutionContext[] pContexts) throws ActionException
If an error occurs when executing the action in one of the given contexts, this method should still try to execute the action in the rest of the contexts before throwing an exception. In the end, an ActionException should be thrown with a FailedActionInfo entry for each failed process execution context.
This default implementation calls executeAction
on each of the contexts. If any of these calls throw a
ProcessException, all the errors are collected, and a single
ActionException is thrown in the end.
execute in interface ActionActionException - if the action failed when executed in
any of the given contexts; the process engine will catch the
ActionException and, for each failed context, respond based on
the value of the action's error response, as specified in the
ActionException itself and/or the action registry; for example,
the engine may ignore the error and continue, or it may delete
the process instance pointed to by the context and stop executing
the process segment in that contextpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String pActionName)
public java.lang.String getActionName()