com.waveset.workflow
Class WorkflowEngine

java.lang.Object
  extended bycom.waveset.workflow.WorkflowEngine
All Implemented Interfaces:
VariableResolver, WorkflowContext

public class WorkflowEngine
extends java.lang.Object
implements WorkflowContext

An object encapsulating the core workflow logic


Field Summary
static java.lang.String ACTION_ADD_RESULT
          An action implemented by checkBuiltinAction that adds an object to the task result.
static java.lang.String ACTION_SET_RESULT
          An action implemented by checkBuiltinAction that adds or modifies a named object in the task result.
static java.lang.String ACTION_SET_RESULT_LIMIT
          An action implemented by checkBuiltinAction that modifies the result limit value of the task instance.
static java.lang.String code_id
           
static java.lang.String VAR_ACTION_ERROR
          Deprecated. Use WFProcess.VAR_ACTION_ERROR
static java.lang.String VAR_ACTION_RESULT
          Deprecated. Use WFProcess.VAR_ACTION_RESULT
static java.lang.String VAR_ACTION_SUPPRESSED
          Deprecated. Use WFProcess.VAR_ACTION_SUPPRESSED
static java.lang.String VAR_ACTION_TIMEOUT
          Deprecated. Use WFProcess.VAR_ACTION_TIMEOUT
static java.lang.String VAR_APPLICATION
          Deprecated. Use WFProcess.VAR_APPLICATION
static java.lang.String VAR_CASE_OWNER
          Deprecated. Use WFProcess.VAR_CASE_OWNER
static java.lang.String VAR_CASE_RESULT
          Deprecated. Use WFProcess.VAR_CASE_RESULT
static java.lang.String VAR_CONTEXT
          Deprecated. Use WFProcess.VAR_CONTEXT
static java.lang.String VAR_TRACE
          Deprecated. Use WFProcess.VAR_TRACE
 
Fields inherited from interface com.waveset.workflow.WorkflowContext
VAR_CASE_TERMINATED
 
Constructor Summary
WorkflowEngine()
          Build an engine.
 
Method Summary
protected  void breakpointEndAndAudit(VariableScope context, com.sun.idm.debugger.common.Locatable target)
           
protected  void breakpointEndAndAudit(VariableScope context, com.sun.idm.debugger.common.Locatable target, java.lang.Object value)
           
protected  void breakpointStartAndAudit(VariableScope context, com.sun.idm.debugger.common.Locatable target)
           
 void execute(LighthouseContext context, WFCase wfcase, java.util.List items)
          This is one of two main entry points for the workflow engine.
 void execute(LighthouseContext context, WFCase wfcase, java.lang.String taskId)
          Execute the case, using the LighthouseContext to manage the work item list.
 com.waveset.security.authz.AccessPolicy getAccessPolicy()
          Returns the access policy object to a WorkflowApplication.
 WFCase.Result getActionResult()
          This is meant to be called only from a WorkflowApplication to find out where they are.
protected  WorkflowApplication getApplication(WFProcess.Action action)
          Locate the class that implements a workflow application for an action.
 java.lang.Object getArgument(java.lang.String name)
          Return the value of an action argument.
 java.util.Map getArguments()
          Return a map of all arguments available to the application.
 ObjectCache getCache()
          Returns an object cache to a WorkflowApplication.
 WavesetResult getCaseResult()
          Obtain the global result being maintained by this case.
 ExState getExpressionState()
          Return the ExState encapsulating all of the workflow variables so that it can be used in rules evaluated by the application.
 LighthouseContext getLighthouseContext()
          Return the lighthouse context.
 LighthouseContext getLighthouseContext(java.lang.String user)
          Return the lighthouse context, configured for a particular user.
 java.util.Map getLockOptions()
          Return the lock options used with LighthouseContext calls.
 com.waveset.repository.Repository getRepository()
          Returns a repository object to a WorkflowApplication.
 Subject getSubject()
          Returns the Subject used for authorizing operations performed by this case.
 TaskInstance getTask()
          Obtain the TaskInstance that contains the executing case.
 java.lang.String getUser()
          Returns the effective user name to a WorkflowApplication.
 java.lang.Object getVariable(java.lang.String name)
          Returns the value of a case variable.
 java.util.Map getVariables()
          Returns a map containing all of the effective case variables.
 void initVariables(Variable[] variables, VariableScope scope)
          Initialize variables defined for a scope.
 boolean isTerminateRequested()
          Test the terminate has been requested in the case.
protected  void markBreakpointStack(VariableScope context)
           
 java.lang.Object resolveVariable(java.lang.String name)
          WorkflowContext now extends VariableResolver, so it needs this too.
 void setExternalTraceControl(boolean b)
           
 void setInterceptor(Interceptor i)
          Install an interceptor for application calls.
 void setInvokeInterceptor(InvokeInterceptor ii)
          Install an interceptor for expressions.
 void setTaskInstance(TaskInstance ti)
           
 void setTerminateRequested(boolean term)
          Set the terminate request case variable.
 void setTolerateUnresolvedOwner(boolean b)
           
 void setTrace(WorkflowTraceBuffer buf)
          Set an externally constructed trace buffer.
 void setVariable(java.lang.String name, java.lang.Object value)
          Sets a case variable.
protected  void unwindBreakpointStack()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

VAR_TRACE

public static final java.lang.String VAR_TRACE
Deprecated. Use WFProcess.VAR_TRACE

See Also:
Constant Field Values

VAR_APPLICATION

public static final java.lang.String VAR_APPLICATION
Deprecated. Use WFProcess.VAR_APPLICATION

See Also:
Constant Field Values

VAR_CASE_OWNER

public static final java.lang.String VAR_CASE_OWNER
Deprecated. Use WFProcess.VAR_CASE_OWNER

See Also:
Constant Field Values

VAR_ACTION_TIMEOUT

public static final java.lang.String VAR_ACTION_TIMEOUT
Deprecated. Use WFProcess.VAR_ACTION_TIMEOUT

See Also:
Constant Field Values

VAR_ACTION_ERROR

public static final java.lang.String VAR_ACTION_ERROR
Deprecated. Use WFProcess.VAR_ACTION_ERROR

See Also:
Constant Field Values

VAR_ACTION_RESULT

public static final java.lang.String VAR_ACTION_RESULT
Deprecated. Use WFProcess.VAR_ACTION_RESULT

See Also:
Constant Field Values

VAR_ACTION_SUPPRESSED

public static final java.lang.String VAR_ACTION_SUPPRESSED
Deprecated. Use WFProcess.VAR_ACTION_SUPPRESSED

See Also:
Constant Field Values

VAR_CONTEXT

public static final java.lang.String VAR_CONTEXT
Deprecated. Use WFProcess.VAR_CONTEXT

See Also:
Constant Field Values

VAR_CASE_RESULT

public static final java.lang.String VAR_CASE_RESULT
Deprecated. Use WFProcess.VAR_CASE_RESULT

See Also:
Constant Field Values

ACTION_ADD_RESULT

public static final java.lang.String ACTION_ADD_RESULT
An action implemented by checkBuiltinAction that adds an object to the task result.

See Also:
Constant Field Values

ACTION_SET_RESULT

public static final java.lang.String ACTION_SET_RESULT
An action implemented by checkBuiltinAction that adds or modifies a named object in the task result.

See Also:
Constant Field Values

ACTION_SET_RESULT_LIMIT

public static final java.lang.String ACTION_SET_RESULT_LIMIT
An action implemented by checkBuiltinAction that modifies the result limit value of the task instance. This can be used to change the result limit after certain conditions in the workflow. For example, the TaskDefinition may specify a zero limit, meaning that results are never stored, but if there is an error in the process the limit can be set non-zero so the results are available for inspection.

See Also:
Constant Field Values
Constructor Detail

WorkflowEngine

public WorkflowEngine()
Build an engine.

Method Detail

setTaskInstance

public void setTaskInstance(TaskInstance ti)

setTolerateUnresolvedOwner

public void setTolerateUnresolvedOwner(boolean b)

setExternalTraceControl

public void setExternalTraceControl(boolean b)

setInterceptor

public void setInterceptor(Interceptor i)
Install an interceptor for application calls.


setInvokeInterceptor

public void setInvokeInterceptor(InvokeInterceptor ii)
Install an interceptor for expressions.


execute

public void execute(LighthouseContext context,
                    WFCase wfcase,
                    java.lang.String taskId)
             throws WavesetException
Execute the case, using the LighthouseContext to manage the work item list.

This entry point is used when it is known that work items are being managed in a persistent store encapsulated with the LighthouseContext. If you want more control over how the work items are managed, you may use the other execute() method that allows the work item list to be passed in and will not attempt to use the LighthouseContext.

Throws:
WavesetException

execute

public void execute(LighthouseContext context,
                    WFCase wfcase,
                    java.util.List items)
             throws WavesetException
This is one of two main entry points for the workflow engine.

Work items to assimilate are passed in a list, new work items will accumulate on the WFCase._newItems list, outstanding work items that become invalid due to transitions will accumulate on the WFCase._invalidItems list. There are no LighthouseContext calls by the engine below this point, though a WorkflowApplication may use it.

Throws:
WavesetException

getLockOptions

public java.util.Map getLockOptions()
Return the lock options used with LighthouseContext calls. This was made public because WorkflowExecutor needs the same stuff in case it needs to store the TaskInstance or WorkItems.


breakpointStartAndAudit

protected void breakpointStartAndAudit(VariableScope context,
                                       com.sun.idm.debugger.common.Locatable target)
                                throws WavesetException
Throws:
WavesetException

breakpointEndAndAudit

protected void breakpointEndAndAudit(VariableScope context,
                                     com.sun.idm.debugger.common.Locatable target)
                              throws WavesetException
Throws:
WavesetException

breakpointEndAndAudit

protected void breakpointEndAndAudit(VariableScope context,
                                     com.sun.idm.debugger.common.Locatable target,
                                     java.lang.Object value)
                              throws WavesetException
Throws:
WavesetException

markBreakpointStack

protected void markBreakpointStack(VariableScope context)

unwindBreakpointStack

protected void unwindBreakpointStack()

initVariables

public void initVariables(Variable[] variables,
                          VariableScope scope)
                   throws WavesetException
Initialize variables defined for a scope. The variables may be from a WFProcess, Activity, or Action. Only initialize if there isn't already a value if this is an external variable, we may search upwards, if this is a local variable, there usually won't be a value, though subcase vars may be initialized by Arguments, and the top-level case may be initialized from task inputs. !! We have historically not left concrete values in the map if the initial value was null. This is confusing in the debugger since variables with no value won't show up in the tree. Reconsider why we can't put a null value into this scope, as long as it isn't an external why not?

Throws:
WavesetException

getApplication

protected WorkflowApplication getApplication(WFProcess.Action action)
                                      throws WavesetException
Locate the class that implements a workflow application for an action.

We maintain a map of previously resolved applications for performance. Note that the application map could be shared by all Executor objects if we end up with many of them.

Similar reflection code now exists in PolicyManager, and will elsewhere. Try to move this somewhere we can share?

We'll keep asking the cache for a configuration object, but if the config changes, we don't currently invalidate the existing map, which may be stale. Could use the new lastMod to keep this in sync.

Throws:
WavesetException

getLighthouseContext

public LighthouseContext getLighthouseContext()
Return the lighthouse context. By default it is configured for the the task owner.

Specified by:
getLighthouseContext in interface WorkflowContext

getLighthouseContext

public LighthouseContext getLighthouseContext(java.lang.String user)
Return the lighthouse context, configured for a particular user.

Specified by:
getLighthouseContext in interface WorkflowContext

getCache

public ObjectCache getCache()
Returns an object cache to a WorkflowApplication.

Specified by:
getCache in interface WorkflowContext

getRepository

public com.waveset.repository.Repository getRepository()
Returns a repository object to a WorkflowApplication.

Specified by:
getRepository in interface WorkflowContext

getAccessPolicy

public com.waveset.security.authz.AccessPolicy getAccessPolicy()
                                                        throws WavesetException
Returns the access policy object to a WorkflowApplication.

Specified by:
getAccessPolicy in interface WorkflowContext
Throws:
WavesetException

getUser

public java.lang.String getUser()
                         throws WavesetException
Returns the effective user name to a WorkflowApplication.

Specified by:
getUser in interface WorkflowContext
Throws:
WavesetException

getSubject

public Subject getSubject()
                   throws WavesetException
Returns the Subject used for authorizing operations performed by this case.

Specified by:
getSubject in interface WorkflowContext
Throws:
WavesetException

getVariable

public java.lang.Object getVariable(java.lang.String name)
                             throws WavesetException
Returns the value of a case variable. This is sensitive to the scopes defined by the _actionResult object.

Specified by:
getVariable in interface WorkflowContext
Throws:
WavesetException

resolveVariable

public java.lang.Object resolveVariable(java.lang.String name)
                                 throws WavesetException
WorkflowContext now extends VariableResolver, so it needs this too.

Specified by:
resolveVariable in interface VariableResolver
Throws:
WavesetException

getVariables

public java.util.Map getVariables()
                           throws WavesetException
Returns a map containing all of the effective case variables. This will be the consolodation of all variable defined in our nested scopes.

Specified by:
getVariables in interface WorkflowContext
Throws:
WavesetException

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
                 throws WavesetException
Sets a case variable.

Specified by:
setVariable in interface WorkflowContext
Throws:
WavesetException

getArgument

public java.lang.Object getArgument(java.lang.String name)
                             throws WavesetException
Return the value of an action argument. These are like variables but kept in their own namespace, and can't be modified.

Specified by:
getArgument in interface WorkflowContext
Throws:
WavesetException

getArguments

public java.util.Map getArguments()
                           throws WavesetException
Return a map of all arguments available to the application.

Used by things that want to pass all the arguments to something else that knows what to look for.

Hmm, not sure I like this... Should we build a new HashMap to be safe?

Specified by:
getArguments in interface WorkflowContext
Throws:
WavesetException

getCaseResult

public WavesetResult getCaseResult()
Obtain the global result being maintained by this case.

Specified by:
getCaseResult in interface WorkflowContext

getTask

public TaskInstance getTask()
Obtain the TaskInstance that contains the executing case. Hmm, I don't really want to expose this but there are times when you'd like to be able to modify characteristics of the task, and I don't feel like exposing a bunch of pseudo variables right now.

Specified by:
getTask in interface WorkflowContext

getActionResult

public WFCase.Result getActionResult()
This is meant to be called only from a WorkflowApplication to find out where they are.

Specified by:
getActionResult in interface WorkflowContext

getExpressionState

public ExState getExpressionState()
Description copied from interface: WorkflowContext
Return the ExState encapsulating all of the workflow variables so that it can be used in rules evaluated by the application.

Specified by:
getExpressionState in interface WorkflowContext

setTrace

public void setTrace(WorkflowTraceBuffer buf)
Set an externally constructed trace buffer.


isTerminateRequested

public boolean isTerminateRequested()
Test the terminate has been requested in the case.

Specified by:
isTerminateRequested in interface WorkflowContext

setTerminateRequested

public void setTerminateRequested(boolean term)
Set the terminate request case variable.