com.ibm.etill.framework.cassette
Class CassetteWorkItem

java.lang.Object
  |
  +--com.ibm.etill.framework.cassette.CassetteRequest
        |
        +--com.ibm.etill.framework.cassette.CassetteWorkItem
All Implemented Interfaces:
Serializable, WorkItem

public abstract class CassetteWorkItem
extends CassetteRequest
implements WorkItem

CassetteWorkItem is the base class for all cassette classes that represent schedulable work items. This class extends CassetteRequest in order to participate in the overall object locking scheme used by the Framework in order to guarantee thread safety and data integrity across concurrently processed requests.

Unlike other classes derived from CassetteRequest, this request is created and scheduled inside of the cassette, rather than originating outside of Commerce Payments. Common uses for CassetteWorkItem objects are:

The specific purpose, characteristics and implementation of each CassetteWorkItem request must be defined by the cassette classes that extend CassetteWorkItem. As with any abstract class, classes that extend CassetteWorkItem must implement all of its abstract methods.

CassetteWorkItem also implements the WorkItem interface in order to provide the necessary semantics for scheduling work using the Framework's service threads (accessed through Supervisor.addItemToServiceQueue). If the cassette wants to schedule CassetteWorkItem objects at a later time using the Framework's timer thread, then they should reference the object to be scheduled within a TimeableTransaction object before calling Supervisor.addItemToTimerQueue.

See Also:
TimeableTransaction, WorkItem, Supervisor.addItemToServiceQueue(com.ibm.etill.framework.supervisor.WorkItem), Supervisor.addItemToTimerQueue(com.ibm.etill.framework.supervisor.TimeableTransaction), Serialized Form

Fields inherited from class com.ibm.etill.framework.cassette.CassetteRequest
monitors, NoLock, ReadLock, WriteLock
 
Constructor Summary
protected CassetteWorkItem(CassetteRequest request, Cassette cassette)
          Constructs a CassetteWorkItem object "copy" of the input request object.
protected CassetteWorkItem(int token, Cassette cassette)
          Constructs a CassetteWorkItem object having the input event token value.
protected CassetteWorkItem(int token, Cassette cassette, MerchantAdmin merchant)
          Constructs a CassetteWorkItem object having the input event token value and belonging to the specified merchant.
 
Method Summary
abstract  void doYourWork()
          Called by the Service thread after this CassetteWorkItem is removed from the service queue for processing.
 Cassette getCassette()
          Returns the cassette associated with this work item.
 
Methods inherited from class com.ibm.etill.framework.cassette.CassetteRequest
addMonitor, clearMonitors, getConnection, getToken, obtainLocks, releaseLocks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CassetteWorkItem

protected CassetteWorkItem(CassetteRequest request,
                           Cassette cassette)
                    throws com.ibm.etill.framework.payapi.ETillAbortOperation
Constructs a CassetteWorkItem object "copy" of the input request object. Effectively, this constructor copies the input request object so that it becomes a schedulable WorkItem. Specifically, the newly constructed object will:
Parameters:
request - the CassetteReqeust object whose token, connection, monitors and Orders will be copied into this new CassetteWorkItem object.
cassette - a reference to the cassette for this work item
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if any errors occur during construction

CassetteWorkItem

protected CassetteWorkItem(int token,
                           Cassette cassette)
Constructs a CassetteWorkItem object having the input event token value. No ETillConnection will be associated with this object. When this item is dispatched to a service thread in the future, the Framework will obtain the following locks while the request is being processed:
ObjectLock TypeEffect
Cassette Write Prevents any other activity within the cassette
Framework Read Prevents any significant configuration changes to Commerce Payments
Parameters:
token - an int containing the event token value to be assigned to this object.
cassette - a reference to the cassette for this work item

CassetteWorkItem

protected CassetteWorkItem(int token,
                           Cassette cassette,
                           MerchantAdmin merchant)
Constructs a CassetteWorkItem object having the input event token value and belonging to the specified merchant. No ETillConnection will be associated with this object. When this item is dispatched to a service thread in the future, the Framework will obtain the following locks while the request is being processed:
ObjectLock TypeEffect
MerchantAdmin Write Prevents any other activity for the merchant
Cassette Read Prevents any significant configuration changes to the cassette
Framework Read Prevents any significant configuration changes to Commerce Payments
Parameters:
token - an int containing the event token value to be assigned to this object.
cassette - a reference to the cassette for this work item
merchant - an MerchantAdmin object representing the merchant to which this work item belongs.
Method Detail

doYourWork

public abstract void doYourWork()
                         throws com.ibm.etill.framework.payapi.ETillAbortOperation
Called by the Service thread after this CassetteWorkItem is removed from the service queue for processing.
Specified by:
doYourWork in interface WorkItem
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - passed through to the Framework if thrown by the cassette while processing the work item. If thrown, the Framework's service threads will subsequently move on to processing the next queued work item.

When this exception is thrown, the service thread will issue a noCommit() call on the thread's current commit point.


getCassette

public Cassette getCassette()
Returns the cassette associated with this work item.
Specified by:
getCassette in interface WorkItem
Returns:
Cassette a reference to the cassette for this work item