org.apache.ode.bpel.engine
Class ProcessAndInstanceManagementImpl

java.lang.Object
  extended by org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl
All Implemented Interfaces:
InstanceManagement, ProcessManagement
Direct Known Subclasses:
BpelManagementFacadeImpl

public class ProcessAndInstanceManagementImpl
extends java.lang.Object
implements InstanceManagement, ProcessManagement

Implentation of the Process and InstanceManagement APIs.


Field Summary
protected static org.apache.commons.logging.Log __log
           
protected static Messages __msgs
           
protected static org.apache.ode.bpel.engine.ProcessStatusConverter __psc
           
protected  java.util.Calendar _calendar
           
protected  BpelDatabase _db
           
protected  BpelServerImpl _server
           
protected  ProcessStore _store
           
 
Constructor Summary
ProcessAndInstanceManagementImpl(BpelServer server, ProcessStore store)
           
 
Method Summary
 ProcessInfoDocument activate(javax.xml.namespace.QName pid)
          Activate a process.
protected
<T> T
dbexec(BpelDatabase.Callable<T> callable)
          Execute a database transaction, unwrapping nested ManagementExceptions.
protected
<T> T
dbexec(org.apache.ode.bpel.engine.BpelProcessDatabase.Callable<T> runnable)
          Execute a database transaction, unwrapping nested ManagementExceptions.
 java.util.Collection<java.lang.Long> delete(java.lang.String filter)
          Delete the process instances matching the given filter.
 InstanceInfoDocument fault(java.lang.Long iid, javax.xml.namespace.QName faultname, org.w3c.dom.Element faultData)
          Causes the process instance to complete unsuccessfully by throwing the specified fault in the global scope.
protected  DebuggerSupport getDebugger(java.lang.Long iid)
          Get the DebuggerSupport object for the given instance identifier.
protected  DebuggerSupport getDebugger(javax.xml.namespace.QName procid)
          Get the DebuggerSupport object for the given process identifier.
 java.util.List<java.lang.String> getEventTimeline(java.lang.String instanceFilter, java.lang.String eventFilter)
          Retrieve a timeline of BPEL events.
 ActivityExtInfoListDocument getExtensibilityElements(javax.xml.namespace.QName pid, java.lang.Integer[] aids)
          Get all extensibility elements associated with provided activity ids.
 InstanceInfoDocument getInstanceInfo(java.lang.Long iid)
          Get an instance by id.
 ProcessInfoDocument getProcessInfo(javax.xml.namespace.QName pid)
          Get the process info for a process (includingthe instance summary).
 ProcessInfoDocument getProcessInfoCustom(javax.xml.namespace.QName pid, ProcessInfoCustomizer custom)
          Get the process info for a process.
 ScopeInfoDocument getScopeInfo(java.lang.String siid)
          Get info about a scope instance by id, not including activity info.
 ScopeInfoDocument getScopeInfoWithActivity(java.lang.String siid, boolean includeActivityInfo)
          Get info about a scope instance by id, optionally including activity info.
 VariableInfoDocument getVariableInfo(java.lang.String scopeId, java.lang.String varName)
          Get info about a variable.
 InstanceInfoListDocument listAllInstances()
          List all instances in the default (database) order.
 InstanceInfoListDocument listAllInstancesWithLimit(int limit)
          List up to limit instances in the default (database) order.
 ProcessInfoListDocument listAllProcesses()
          List the processes known to the engine.
 EventInfoListDocument listEvents(java.lang.String instanceFilter, java.lang.String eventFilter, int maxCount)
          Retrieve BPEL events.
 InstanceInfoListDocument listInstances(java.lang.String filter, java.lang.String order, int limit)
           Retrieve and returns information about all, or some process instances.
 InstanceInfoListDocument listInstancesSummary(java.lang.String filter, java.lang.String order, int limit)
          List instances and only return summary information about the instance, combined with all correlation properties.
 ProcessInfoListDocument listProcesses(java.lang.String filter, java.lang.String orderKeys)
          List the processes known to the engine (including instance summaries).
 ProcessInfoListDocument listProcessesCustom(java.lang.String filter, java.lang.String orderKeys, ProcessInfoCustomizer custom)
          List the processes known to the engine.
 InstanceInfoListDocument queryInstances(java.lang.String query)
          Deprecated. use listInstances instead
 InstanceInfoDocument recoverActivity(java.lang.Long iid, java.lang.Long aid, java.lang.String action)
          Performs an activity recovery action.
 InstanceInfoDocument resume(java.lang.Long iid)
          Resume the (previously suspended) instance.
 void setPackageRetired(java.lang.String packageName, boolean retired)
          Retires all the processes contained in a package.
 ProcessInfoDocument setProcessProperty(javax.xml.namespace.QName pid, javax.xml.namespace.QName propertyName, java.lang.String value)
          Set a process property as a simple type.
 ProcessInfoDocument setProcessPropertyNode(javax.xml.namespace.QName pid, javax.xml.namespace.QName propertyName, org.w3c.dom.Node value)
          Set a process property as a Node.
 ProcessInfoDocument setRetired(javax.xml.namespace.QName pid, boolean retired)
          Retire a process.
 InstanceInfoDocument suspend(java.lang.Long iid)
          Changes the process state from active to suspended.
 InstanceInfoDocument terminate(java.lang.Long iid)
          Causes the process instance to terminate immediately, without a chance to perform any fault handling or compensation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__msgs

protected static final Messages __msgs

__log

protected static org.apache.commons.logging.Log __log

__psc

protected static final org.apache.ode.bpel.engine.ProcessStatusConverter __psc

_db

protected BpelDatabase _db

_store

protected ProcessStore _store

_calendar

protected java.util.Calendar _calendar

_server

protected BpelServerImpl _server
Constructor Detail

ProcessAndInstanceManagementImpl

public ProcessAndInstanceManagementImpl(BpelServer server,
                                        ProcessStore store)
Method Detail

listProcessesCustom

public ProcessInfoListDocument listProcessesCustom(java.lang.String filter,
                                                   java.lang.String orderKeys,
                                                   ProcessInfoCustomizer custom)
Description copied from interface: ProcessManagement
List the processes known to the engine.

Specified by:
listProcessesCustom in interface ProcessManagement
Parameters:
filter - selection filter or null (for no filtering).
orderKeys - keys used to order the results
custom - used to customize the quantity of information returned
Returns:
list of ProcessInfoDocuments (including instance summaries)

listProcesses

public ProcessInfoListDocument listProcesses(java.lang.String filter,
                                             java.lang.String orderKeys)
Description copied from interface: ProcessManagement
List the processes known to the engine (including instance summaries).

Specified by:
listProcesses in interface ProcessManagement
Parameters:
filter - selection filter or null (for no filtering).
orderKeys - keys used to order the results
Returns:
list of ProcessInfoDocuments (including instance summaries)

listAllProcesses

public ProcessInfoListDocument listAllProcesses()
Description copied from interface: ProcessManagement
List the processes known to the engine.

Specified by:
listAllProcesses in interface ProcessManagement
Returns:
list of ProcessInfoDocuments (including instance summaries)

getProcessInfoCustom

public ProcessInfoDocument getProcessInfoCustom(javax.xml.namespace.QName pid,
                                                ProcessInfoCustomizer custom)
Description copied from interface: ProcessManagement
Get the process info for a process.

Specified by:
getProcessInfoCustom in interface ProcessManagement
Parameters:
pid - name of the process
custom - used to customize the quantity of information returned
Returns:
ProcessInfoDocument

getProcessInfo

public ProcessInfoDocument getProcessInfo(javax.xml.namespace.QName pid)
Description copied from interface: ProcessManagement
Get the process info for a process (includingthe instance summary).

Specified by:
getProcessInfo in interface ProcessManagement
Parameters:
pid - name of the process
Returns:
ProcessInfoDocument with all details.

activate

public ProcessInfoDocument activate(javax.xml.namespace.QName pid)
Description copied from interface: ProcessManagement
Activate a process.

Specified by:
activate in interface ProcessManagement
Parameters:
pid - identifier for the process to load
Returns:
ProcessInfoDocument reflecting the modification

setRetired

public ProcessInfoDocument setRetired(javax.xml.namespace.QName pid,
                                      boolean retired)
                               throws ManagementException
Description copied from interface: ProcessManagement
Retire a process.

Specified by:
setRetired in interface ProcessManagement
Parameters:
pid - identifier of the process to retire
retired - new value of retired flag
Returns:
ProcessInfoDocument reflecting the modification
Throws:
ManagementException

setPackageRetired

public void setPackageRetired(java.lang.String packageName,
                              boolean retired)
                       throws ManagementException
Description copied from interface: ProcessManagement
Retires all the processes contained in a package.

Specified by:
setPackageRetired in interface ProcessManagement
Throws:
ManagementException

setProcessPropertyNode

public ProcessInfoDocument setProcessPropertyNode(javax.xml.namespace.QName pid,
                                                  javax.xml.namespace.QName propertyName,
                                                  org.w3c.dom.Node value)
                                           throws ManagementException
Description copied from interface: ProcessManagement
Set a process property as a Node.

Specified by:
setProcessPropertyNode in interface ProcessManagement
Parameters:
pid - name of process
propertyName - qname of property
value - property value
Returns:
ProcessInfoDocument reflecting the modification
Throws:
ManagementException

setProcessProperty

public ProcessInfoDocument setProcessProperty(javax.xml.namespace.QName pid,
                                              javax.xml.namespace.QName propertyName,
                                              java.lang.String value)
                                       throws ManagementException
Description copied from interface: ProcessManagement
Set a process property as a simple type.

Specified by:
setProcessProperty in interface ProcessManagement
Parameters:
pid - name of process
propertyName - qname of property
value - property value
Returns:
ProcessInfoDocument reflecting the modification
Throws:
ManagementException

listInstances

public InstanceInfoListDocument listInstances(java.lang.String filter,
                                              java.lang.String order,
                                              int limit)
Description copied from interface: InstanceManagement

Retrieve and returns information about all, or some process instances. The request identifies the process instances using a filter that can select instances with a given name, status, property values, etc. Without a filter, the operation returns all process instances up to a specified limit<.code>. The request also indicates which key fields to use for ordering the results.

The filter element can be used to narrow down the list of process definitions by applying selection criteria. There are six filters that can be applied:

  • name -- Only process instances with this local name.

  • namespace -- Only process instances with this namespace URI.

  • status -- Only process instances with these status code(s).

  • started -- Only process instances started relative to this date/time.

  • last-active -- Only process instances last active relative to this date/time.

  • $property -- Only process instances with a correlation property equal to the specified value.

The name and namespace filters can do full or partial name matching. Partial matching occurs if either filter ends with an asterisk (*). These filters are not case sensitive, for example name=my* will match MyProcess and my-process. If unspecified, the default filter is name=* namespace=*.

The status filter can be used to filter all process definitions based on six status codes:

  • active -- All currently active process instances (excludes instances in any other state).

  • suspended -- All process instances that have not completed, but are currently suspended.

  • error -- All process instances that have not completed, but are currently indicate an error condition.

  • completed -- All successfully completed process instances (excludes instances in any other state).

  • terminated -- All process instances that were terminated.

  • faulted -- All process instances that encountered a fault (in the global scope).

The started filter can be used to filter all process instances started on or after a particular date or date/time instant. The value of this filter is either an ISO-8601 date or ISO-8601 date/time. For example, to find all process instances started on or after September 1, 2005, use started>=20050901. Similarly, the last-active filter can be used to filter all process instances based on their last active time. The last active time records when the process last completed performing work, and either completed or is now waiting to receive a message, a timeout or some other event.

Each process instance has one or more properties that are set its instantiation, that can be used to distinguish it from other process instances. In this version of the specification, we only support properties instantiated as part of correlation sets defined in the global scope of the process. For example, if a process instantiates a correlation set that uses the property order-id, it is possible to filter that process instance based on the value of that property.

The property name is identified by the prefix $. If the property name is an NCName, the filter will match all properties with that local name. If the property name is {namespace}local, the filter will match all properties with the specified namespace URI and local name. For example, to retrieve a list of all active process instances with a property order-id that has the value 456, use status=active $order-id=456.

By default the response returns process instances in no particular order. The order element can be used to order the results by specifying a space-separated list of keys. Each key can be prefixed with a plus sign '+' to specify ascending order, or a '-' minus sign to specify descending order. Without a sign the default behavior is to return process instances in ascending order. The currently supported odering keys are:

  • pid

  • -- Order based on the process identifier.
  • name

  • -- Order based on the local name of the process instance.
  • namespace

  • -- Order based on the namespace URI of the process instance.
  • version

  • -- Order based on the version number.
  • status

  • -- Order based on the status of the process instance.
  • started

  • -- Order based on the process instance start date/time.
  • last-active

  • -- Order based on the process instance last active date/time.

Specified by:
listInstances in interface InstanceManagement
Parameters:
filter - filter string
order - order keys
limit - maximum number of instances to return
Returns:
list of matching instances

listInstancesSummary

public InstanceInfoListDocument listInstancesSummary(java.lang.String filter,
                                                     java.lang.String order,
                                                     int limit)
Description copied from interface: InstanceManagement
List instances and only return summary information about the instance, combined with all correlation properties.

Specified by:
listInstancesSummary in interface InstanceManagement
Parameters:
filter - See listInstances' filter argument
order - See listInstances' order argument
limit - maximum number of instances to return
Returns:
list of matching instances

listAllInstances

public InstanceInfoListDocument listAllInstances()
Description copied from interface: InstanceManagement
List all instances in the default (database) order.

Specified by:
listAllInstances in interface InstanceManagement
Returns:
list of matching instances
See Also:
InstanceManagement.listInstances(String, String, int)

listAllInstancesWithLimit

public InstanceInfoListDocument listAllInstancesWithLimit(int limit)
Description copied from interface: InstanceManagement
List up to limit instances in the default (database) order.

Specified by:
listAllInstancesWithLimit in interface InstanceManagement
Parameters:
limit - maximum number of instances to return
Returns:
list of matching instances
See Also:
InstanceManagement.listInstances(String, String, int)

getInstanceInfo

public InstanceInfoDocument getInstanceInfo(java.lang.Long iid)
                                     throws InstanceNotFoundException
Description copied from interface: InstanceManagement
Get an instance by id.

Specified by:
getInstanceInfo in interface InstanceManagement
Returns:
information about a specific instance
Throws:
InstanceNotFoundException

getScopeInfo

public ScopeInfoDocument getScopeInfo(java.lang.String siid)
Description copied from interface: InstanceManagement
Get info about a scope instance by id, not including activity info.

Specified by:
getScopeInfo in interface InstanceManagement
Parameters:
siid - scope instance identifier
Returns:
information about a specific scope instance
See Also:
InstanceManagement.getScopeInfoWithActivity(String, boolean)

getScopeInfoWithActivity

public ScopeInfoDocument getScopeInfoWithActivity(java.lang.String siid,
                                                  boolean includeActivityInfo)
Description copied from interface: InstanceManagement
Get info about a scope instance by id, optionally including activity info.

Specified by:
getScopeInfoWithActivity in interface InstanceManagement
Parameters:
siid - scope instance identifier
includeActivityInfo - if true, include activity info
Returns:
information about a specific scope instance

getVariableInfo

public VariableInfoDocument getVariableInfo(java.lang.String scopeId,
                                            java.lang.String varName)
                                     throws ManagementException
Description copied from interface: InstanceManagement
Get info about a variable.

Specified by:
getVariableInfo in interface InstanceManagement
Parameters:
scopeId - scope identifier
varName - variable name
Returns:
information about variable (basically the value)
Throws:
ManagementException

fault

public InstanceInfoDocument fault(java.lang.Long iid,
                                  javax.xml.namespace.QName faultname,
                                  org.w3c.dom.Element faultData)
Description copied from interface: InstanceManagement
Causes the process instance to complete unsuccessfully by throwing the specified fault in the global scope. The process is able to perform recovery using a fault handler in the global scope, through termination handlers in nested scopes and by invoking installed compensation handlers. The process will transition to the faulted state.

Specified by:
fault in interface InstanceManagement
Parameters:
iid - instance id
faultname - name of the fault
faultData - fault data
Returns:
post-change instance information

resume

public InstanceInfoDocument resume(java.lang.Long iid)
Description copied from interface: InstanceManagement
Resume the (previously suspended) instance. This operation only affects process instances that are in the suspended state.

Specified by:
resume in interface InstanceManagement
Parameters:
iid - instance id
Returns:
post-change instance information

suspend

public InstanceInfoDocument suspend(java.lang.Long iid)
                             throws ManagementException
Description copied from interface: InstanceManagement
Changes the process state from active to suspended. this affects process instances that are in the active or error states.

Specified by:
suspend in interface InstanceManagement
Parameters:
iid - instance id
Returns:
post-change instance information
Throws:
ManagementException

terminate

public InstanceInfoDocument terminate(java.lang.Long iid)
                               throws ManagementException
Description copied from interface: InstanceManagement
Causes the process instance to terminate immediately, without a chance to perform any fault handling or compensation. The process transitions to the terminated state. It only affects process instances that are in the active, suspended or error states.

Specified by:
terminate in interface InstanceManagement
Parameters:
iid - instance id
Returns:
post-change instance information
Throws:
ManagementException

recoverActivity

public InstanceInfoDocument recoverActivity(java.lang.Long iid,
                                            java.lang.Long aid,
                                            java.lang.String action)
Description copied from interface: InstanceManagement
Performs an activity recovery action.

Specified by:
recoverActivity in interface InstanceManagement
Parameters:
iid - instance id (process)
action - recovery action (e.g. retry, fault)
Returns:
post-change instance information

delete

public java.util.Collection<java.lang.Long> delete(java.lang.String filter)
Description copied from interface: InstanceManagement
Delete the process instances matching the given filter.

Specified by:
delete in interface InstanceManagement
Parameters:
filter - instance filter (see InstanceManagement.listInstances(String, String, int) ).
Returns:
collection of instances identfiers, corresponding to deleted instances

getEventTimeline

public java.util.List<java.lang.String> getEventTimeline(java.lang.String instanceFilter,
                                                         java.lang.String eventFilter)
Description copied from interface: InstanceManagement
Retrieve a timeline of BPEL events.

Specified by:
getEventTimeline in interface InstanceManagement
Parameters:
instanceFilter - instance filter (if set,return only events for matching instances)
eventFilter - event filter (event type and data range)
Returns:
list of stringified dates (in ISO format)

listEvents

public EventInfoListDocument listEvents(java.lang.String instanceFilter,
                                        java.lang.String eventFilter,
                                        int maxCount)
Description copied from interface: InstanceManagement
Retrieve BPEL events. One may specify an "instance filter" and an "event filter" to limit the number of events returned. The instance filter takes the exact same syntax as for the InstanceManagement.listInstances(String, String, int) method. The "event filter" employs a similar syntax; the following properties may be filtered:
  1. type - the event type
  2. tstamp - the event timestamp

Specified by:
listEvents in interface InstanceManagement
Parameters:
instanceFilter - instance filter (if set,return only events for matching instances)
eventFilter - event filter (event type and data range)
Returns:
list of events

getExtensibilityElements

public ActivityExtInfoListDocument getExtensibilityElements(javax.xml.namespace.QName pid,
                                                            java.lang.Integer[] aids)
Description copied from interface: ProcessManagement
Get all extensibility elements associated with provided activity ids. Extensibility elements are extracted from the original BPEL document.

Specified by:
getExtensibilityElements in interface ProcessManagement
Parameters:
pid - process identifier
aids - activity indentifiers
Returns:
a list of activity extension as ActivityExtInfoListDocument

getDebugger

protected final DebuggerSupport getDebugger(javax.xml.namespace.QName procid)
                                     throws ManagementException
Get the DebuggerSupport object for the given process identifier. Debugger support is required for operations that resume execution in some way or manipulate the breakpoints.

Parameters:
procid - process identifier
Returns:
associated debugger support object
Throws:
ManagementException

getDebugger

protected final DebuggerSupport getDebugger(java.lang.Long iid)
Get the DebuggerSupport object for the given instance identifier. Debugger support is required for operations that resume execution in some way or manipulate the breakpoints.

Parameters:
iid - instance identifier
Returns:
associated debugger support object
Throws:
ManagementException

dbexec

protected <T> T dbexec(org.apache.ode.bpel.engine.BpelProcessDatabase.Callable<T> runnable)
            throws ManagementException
Execute a database transaction, unwrapping nested ManagementExceptions.

Parameters:
runnable - action to run
Returns:
Throws:
ManagementException

dbexec

protected <T> T dbexec(BpelDatabase.Callable<T> callable)
            throws ManagementException
Execute a database transaction, unwrapping nested ManagementExceptions.

Parameters:
callable - action to run
Returns:
Throws:
ManagementException

queryInstances

public InstanceInfoListDocument queryInstances(java.lang.String query)
Deprecated. use listInstances instead

Specified by:
queryInstances in interface InstanceManagement
See Also:
InstanceManagement.queryInstances(java.lang.String)