org.yawlfoundation.yawl.worklet.exception
Class ExceptionService

java.lang.Object
  extended by org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
      extended by org.yawlfoundation.yawl.worklet.WorkletService
          extended by org.yawlfoundation.yawl.worklet.exception.ExceptionService
All Implemented Interfaces:
InterfaceX_Service

public class ExceptionService
extends WorkletService
implements InterfaceX_Service

The ExceptionService class manages the handling of exceptions that may occur during the life of a case instance. It receives events from the engine via InterfaceX at various milestones for constraint checking, and when certain exceptional events occur. It runs exception handlers when required, which may involve the running of compensatory worklets. It derives from the WorkletService class and uses many of the same methods as those used in the worklet selection process.

Version:
0.8, 04-09/2006
Author:
Michael Adams

Field Summary
 
Fields inherited from class org.yawlfoundation.yawl.worklet.WorkletService
_dbMgr, _engineURI, _loadedSpecs, _persisting, _rdr, _server, _sessionHandle, _workletURI
 
Fields inherited from class org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
_ibCache, _interfaceBClient, _logger, _report, engineLogonName, engineLogonPassword, XSD_ANYURI_TYPE, XSD_NAMESPACE, XSD_NCNAME_TYPE, XSD_STRINGTYPE
 
Constructor Summary
ExceptionService()
          HashMap mappings: _monitoredCases: - KEY: [String] case id of case being monitored - VALUE: [CaseMonitor] obj describing the monitored case _handlersStarted: - KEY: [String] case id of a launched worklet compensatory case - VALUE: [HandlerRunner] obj managing the exception process of which the launched worklet is part
 
Method Summary
 void completeInitialisation()
          completes the initialisation of the service load-up (mainly persistence) called from servlet WorkletGateway after contexts are loaded
 List getExternalTriggersForCase(String caseID)
          retrieves a complete list of external exception triggers from the ruleset for the specified case
 List getExternalTriggersForItem(String itemID)
          retrieves a complete list of external exception triggers from the ruleset for the specified workitem
static ExceptionService getInst()
           
 YSpecificationID getSpecIDForCaseID(String caseID)
          returns the spec id for the specified case id
 String getStatus(String taskName)
          stub method called from RdrConditionFunctions class
 WorkItemRecord getWorkItemRecord(String itemID)
          returns the specified wir for the id passed
 void handleCaseCancellationEvent(String caseID)
          Handles a notification from the Engine that a case has been cancelled.
 void handleCheckCaseConstraintEvent(YSpecificationID specID, String caseID, String data, boolean preCheck)
          Handles a notification from the Engine that a case is either starting or has completed.
 void handleCheckWorkItemConstraintEvent(WorkItemRecord wir, String data, boolean preCheck)
          Handles a notification from the Engine that a workitem is either starting or has completed.
 String handleConstraintViolationException(WorkItemRecord wir, String data)
           
 void handleResourceUnavailableException(String resourceID, WorkItemRecord wir, String caseData, boolean primary)
           
 void handleTimeoutEvent(WorkItemRecord wir, String taskList)
          Handles a notification from the Engine that a workitem associated with the timeService has timed out.
 String handleWorkItemAbortException(WorkItemRecord wir, String data)
           
 boolean isWorkletCase(String caseID)
          returns true if case specified is a worklet instance
protected  boolean launchWorkletList(HandlerRunner hr, String list)
          Launches each of the worklets listed in the hr for starting
 void raiseExternalException(String level, String id, String trigger)
          Raise an externally triggered exception
 String replaceWorklet(RuleType xType, String caseid, String itemid, String trigger)
          Replaces a running worklet case with another worklet case after an amendment to the ruleset for this exception.
 void setupInterfaceXListener(String workletURI)
          registers this ExceptionService instance with the Engine
 boolean suspendCase(String caseID)
          Suspends all live workitems in the specified case
 boolean suspendWorkItem(String itemID)
           
 
Methods inherited from class org.yawlfoundation.yawl.worklet.WorkletService
addAdministrationTask, addAdministrationTask, cancelWorkletList, checkOutChildren, checkOutParentItem, checkOutWorkItem, completeAdminTask, connected, doGet, getAdminTask, getAdminTaskTitles, getAllAdminTasksAsList, getEngineStoredWorkItem, getInstance, getRdrInterface, getServer, getTree, getWorkletFileName, getWorkletSpecID, handleCancelledCaseEvent, handleCancelledWorkItemEvent, handleCompleteCaseEvent, handleEnabledWorkItemEvent, handleEngineInitialisationCompletedEvent, initEngineURI, isAdminSession, isExceptionServiceEnabled, launchWorklet, launchWorkletList, loadTree, refreshRuleSet, registerExceptionService, replaceWorklet, setExceptionServiceEnabled, setWorkletURI, shutdown, updateDataList, uploadWorklet
 
Methods inherited from class org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
checkConnection, checkInWorkItem, checkInWorkItem, checkInWorkItem, checkOut, checkOutAllInstancesOfThisTask, connect, describeRequiredParams, destroy, getAuthenticationConfig, getCachedWorkItem, getChildren, getEngineStoredWorkItem, getIBCache, getModel, getResourcingSpecs, getSpecificationData, getSpecificationData, getSpecificationPrototypesList, getTaskInformation, getTaskInformation, handleCaseResumedEvent, handleCaseSuspendedEvent, handleCaseSuspendingEvent, handleStartCaseEvent, handleTimerExpiryEvent, handleWorkItemStatusChangeEvent, logContactError, prepareReplyRootElement, setEngineLogonName, setEngineLogonPassword, setRemoteAuthenticationDetails, setUpInterfaceBClient, successful
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.yawlfoundation.yawl.engine.interfce.interfaceX.InterfaceX_Service
doGet
 

Constructor Detail

ExceptionService

public ExceptionService()
HashMap mappings: _monitoredCases: - KEY: [String] case id of case being monitored - VALUE: [CaseMonitor] obj describing the monitored case _handlersStarted: - KEY: [String] case id of a launched worklet compensatory case - VALUE: [HandlerRunner] obj managing the exception process of which the launched worklet is part

Method Detail

getInst

public static ExceptionService getInst()

completeInitialisation

public void completeInitialisation()
Description copied from class: WorkletService
completes the initialisation of the service load-up (mainly persistence) called from servlet WorkletGateway after contexts are loaded

Overrides:
completeInitialisation in class WorkletService

handleCaseCancellationEvent

public void handleCaseCancellationEvent(String caseID)
Handles a notification from the Engine that a case has been cancelled. If the case passed has any exception handling worklets running for it, they are also cancelled.

Specified by:
handleCaseCancellationEvent in interface InterfaceX_Service
Parameters:
caseID - the case cancelled by the Engine

handleCheckWorkItemConstraintEvent

public void handleCheckWorkItemConstraintEvent(WorkItemRecord wir,
                                               String data,
                                               boolean preCheck)
Handles a notification from the Engine that a workitem is either starting or has completed. Checks the rules for the workitem, and evaluates any pre-constraints or post-constraints (if any), and if a constraint has been violated, raises the appropriate exception.

Specified by:
handleCheckWorkItemConstraintEvent in interface InterfaceX_Service
Parameters:
wir - the workitem that triggered the event
data - the workitem's data params
preCheck - true for pre-constraints, false for post-constraints

handleCheckCaseConstraintEvent

public void handleCheckCaseConstraintEvent(YSpecificationID specID,
                                           String caseID,
                                           String data,
                                           boolean preCheck)
Handles a notification from the Engine that a case is either starting or has completed. Checks the rules for the case and evaluates any pre-constraints or post-constraints (if any), and if a constraint has been violated, raises the appropriate exception.

Specified by:
handleCheckCaseConstraintEvent in interface InterfaceX_Service
Parameters:
specID - specification id of the case
caseID - the id for the case
data - the case-level data params
preCheck - true for pre-constraints, false for post-constraints

handleTimeoutEvent

public void handleTimeoutEvent(WorkItemRecord wir,
                               String taskList)
Handles a notification from the Engine that a workitem associated with the timeService has timed out. Checks the rules for timeout for the other items associated withthis timeout item and raises thr appropriate exception.

Specified by:
handleTimeoutEvent in interface InterfaceX_Service
Parameters:
wir - - the item that caused thetimeout event
taskList - - a list of taskids of those tasks that were running in parallel with the timeout task

handleResourceUnavailableException

public void handleResourceUnavailableException(String resourceID,
                                               WorkItemRecord wir,
                                               String caseData,
                                               boolean primary)
Specified by:
handleResourceUnavailableException in interface InterfaceX_Service

handleWorkItemAbortException

public String handleWorkItemAbortException(WorkItemRecord wir,
                                           String data)
Specified by:
handleWorkItemAbortException in interface InterfaceX_Service

handleConstraintViolationException

public String handleConstraintViolationException(WorkItemRecord wir,
                                                 String data)
Specified by:
handleConstraintViolationException in interface InterfaceX_Service

launchWorkletList

protected boolean launchWorkletList(HandlerRunner hr,
                                    String list)
Launches each of the worklets listed in the hr for starting

Parameters:
hr - - the worklet record containing the list of worklets to launch
Returns:
true if *any* of the worklets are successfully launched

suspendWorkItem

public boolean suspendWorkItem(String itemID)

suspendCase

public boolean suspendCase(String caseID)
Suspends all live workitems in the specified case

Parameters:
caseID - - the id of the case to suspend
Returns:
true on successful suspend

setupInterfaceXListener

public void setupInterfaceXListener(String workletURI)
registers this ExceptionService instance with the Engine


getWorkItemRecord

public WorkItemRecord getWorkItemRecord(String itemID)
returns the specified wir for the id passed


getSpecIDForCaseID

public YSpecificationID getSpecIDForCaseID(String caseID)
returns the spec id for the specified case id


getExternalTriggersForCase

public List getExternalTriggersForCase(String caseID)
retrieves a complete list of external exception triggers from the ruleset for the specified case

Parameters:
caseID - - the id of the case to get the triggers for
Returns:
the (String) list of triggers

getExternalTriggersForItem

public List getExternalTriggersForItem(String itemID)
retrieves a complete list of external exception triggers from the ruleset for the specified workitem

Parameters:
itemID - - the id of the item to get the triggers for
Returns:
the (String) list of triggers

raiseExternalException

public void raiseExternalException(String level,
                                   String id,
                                   String trigger)
Raise an externally triggered exception

Parameters:
level - - the level of the exception (case/item)
id - - the id of the case or item on which the exception is being raised
trigger - - the identifier of (or reason for) the external exception

replaceWorklet

public String replaceWorklet(RuleType xType,
                             String caseid,
                             String itemid,
                             String trigger)
Replaces a running worklet case with another worklet case after an amendment to the ruleset for this exception. Called by WorkletGateway after a call from the RdrEditor that the ruleset has been updated. Overrides the WorkletService equivalent - This one looks after exceptions, that one looks after selections

Parameters:
xType - - the type of exception that launched the worklet
caseid - - the id of the orginal checked out case
itemid - - the id of the orginal checked out workitem
Returns:
a string of messages decribing the success or otherwise of the process

isWorkletCase

public boolean isWorkletCase(String caseID)
returns true if case specified is a worklet instance

Overrides:
isWorkletCase in class WorkletService

getStatus

public String getStatus(String taskName)
stub method called from RdrConditionFunctions class



Copyright © 2004-2012 The YAWL Foundation.