com.jboss.jbossnetwork.product.jbpm.handlers
Class BaseHandler

java.lang.Object
  extended by com.jboss.jbossnetwork.product.jbpm.handlers.BaseHandler
All Implemented Interfaces:
Serializable, org.jbpm.graph.def.ActionHandler
Direct Known Subclasses:
BackupAndReplaceFileActionHandler, CompareDigestActionHandler, ControlActionHandler, JONServerDownloadActionHandler, NotificationActionHandler, UnzipActionHandler

public abstract class BaseHandler
extends Object
implements org.jbpm.graph.def.ActionHandler

Base class for all of our JBPM handlers, providing some basic functionality for transitioning between steps.

Author:
Jason Dobies
See Also:
Serialized Form

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger, keyed to the subclass.
protected static String MESSAGE_NO_CHANGES
          Standard message to describe that no changes were made by the currently executing step.
protected static String TRANSITION_ERROR
          Describes an error in a step, preventing transitioning.
protected static String TRANSITION_SUCCESS
          Describes a successful transition between steps.
 
Constructor Summary
BaseHandler()
           
 
Method Summary
protected  void checkProperties()
          Ensures the property values that were set in substituteVariables(org.jbpm.graph.exe.ExecutionContext) are valid.
protected  void complete(org.jbpm.graph.exe.ExecutionContext executionContext, String message)
          Called by a handler at the end of its processing to indicate a step was completed successfully and transitions to the next step in the workflow.
protected  void error(org.jbpm.graph.exe.ExecutionContext executionContext, Throwable throwable, String additionalMessage, String leavingTransition)
          Called by a handler at the end of its processing to indicate an error occurred in the execution of a given step and closes out the step.
 void execute(org.jbpm.graph.exe.ExecutionContext executionContext)
           
abstract  String getDescription()
          Returns a user readable description of what the step in the workflow entails.
protected  void notRun(org.jbpm.graph.exe.ExecutionContext executionContext, String message)
          Called by a handler at the end of its processing to indicate a step was skipped and transitions to the next step in the workflow.
abstract  void run(org.jbpm.graph.exe.ExecutionContext executionContext)
          Tells the handle implementation to actually perform the step indicated.
 void setPropertyDefaults()
          Sets the default values for properties used by the handler implementation.
protected  void skip(org.jbpm.graph.exe.ExecutionContext executionContext, ActionHandlerException exception, String additionalMessage, String leavingTransition)
          Called by a handler at the end of its processing to indicate a step in the workflow has been skipped and transitions to the next step in the workflow.
protected  String substituteVariable(String expression, org.jbpm.graph.exe.ExecutionContext executionContext)
          Substitutes in values found in the workflow (execution context) for the specified expression.
 void substituteVariables(org.jbpm.graph.exe.ExecutionContext executionContext)
          Requests the action handler substitute into its node any variables necessary, taking the values for these from the provided execution context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSITION_SUCCESS

protected static final String TRANSITION_SUCCESS
Describes a successful transition between steps.

See Also:
Constant Field Values

TRANSITION_ERROR

protected static final String TRANSITION_ERROR
Describes an error in a step, preventing transitioning.

See Also:
Constant Field Values

MESSAGE_NO_CHANGES

protected static final String MESSAGE_NO_CHANGES
Standard message to describe that no changes were made by the currently executing step.

See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Logger, keyed to the subclass.

Constructor Detail

BaseHandler

public BaseHandler()
Method Detail

getDescription

public abstract String getDescription()
Returns a user readable description of what the step in the workflow entails.

Returns:
should not be null

run

public abstract void run(org.jbpm.graph.exe.ExecutionContext executionContext)
Tells the handle implementation to actually perform the step indicated.

Parameters:
executionContext - cannot be null

setPropertyDefaults

public void setPropertyDefaults()
Sets the default values for properties used by the handler implementation. This may optionally be overridden by action handler implementations if necessary.


substituteVariables

public void substituteVariables(org.jbpm.graph.exe.ExecutionContext executionContext)
                         throws ActionHandlerException
Requests the action handler substitute into its node any variables necessary, taking the values for these from the provided execution context. This may optionally be overridden by action handler implementations if necessary.

Parameters:
executionContext - JBPM execution context from which the property values should be extracted
Throws:
ActionHandlerException - if there is an error extraction or substituting the variables

checkProperties

protected void checkProperties()
                        throws ActionHandlerException
Ensures the property values that were set in substituteVariables(org.jbpm.graph.exe.ExecutionContext) are valid. This may optionally be overridden by action handler implementations if necessary.

Throws:
ActionHandlerException - if any of the properties are invalid

execute

public void execute(org.jbpm.graph.exe.ExecutionContext executionContext)
             throws Exception
Specified by:
execute in interface org.jbpm.graph.def.ActionHandler
Throws:
Exception

error

protected void error(org.jbpm.graph.exe.ExecutionContext executionContext,
                     Throwable throwable,
                     String additionalMessage,
                     String leavingTransition)
Called by a handler at the end of its processing to indicate an error occurred in the execution of a given step and closes out the step.

Parameters:
executionContext - context in which the step was executing
throwable - exception that occurred to trigger this call to error
additionalMessage - additional details to report on the step
leavingTransition - ?

complete

protected void complete(org.jbpm.graph.exe.ExecutionContext executionContext,
                        String message)
Called by a handler at the end of its processing to indicate a step was completed successfully and transitions to the next step in the workflow.

Parameters:
executionContext - context in which the step was executing
message - additional details on the step

skip

protected void skip(org.jbpm.graph.exe.ExecutionContext executionContext,
                    ActionHandlerException exception,
                    String additionalMessage,
                    String leavingTransition)
Called by a handler at the end of its processing to indicate a step in the workflow has been skipped and transitions to the next step in the workflow.

Parameters:
executionContext - context in which the step was executing
exception - exception that occurred to trigger this call to error
additionalMessage - additional details to report on the step
leavingTransition - ?

notRun

protected void notRun(org.jbpm.graph.exe.ExecutionContext executionContext,
                      String message)
Called by a handler at the end of its processing to indicate a step was skipped and transitions to the next step in the workflow.

Parameters:
executionContext - context in which the step was executing
message - additional details on the step

substituteVariable

protected String substituteVariable(String expression,
                                    org.jbpm.graph.exe.ExecutionContext executionContext)
                             throws ActionHandlerException
Substitutes in values found in the workflow (execution context) for the specified expression.

Parameters:
expression - expression into which to substitute values from the workflow
executionContext - context describing the workflow
Returns:
expression with the proper values substituted in; null if the expression is null
Throws:
ActionHandlerException - if there is an error during the substitution


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.