com.ibm.etill.ldbcardcassette
Class LdbCardBatch.TimeOfDayWorkItem
com.ibm.etill.ldbcardcassette.LdbCardBatch.TimeOfDayWorkItem
- Enclosing class:
- LdbCardBatch
- public final class LdbCardBatch.TimeOfDayWorkItem
The TimeOfDayWorkItem object is used to automatically close an
open batch at a particular time of day (specified in minutes after
midnight). When constructed, it automatically schedules itself
using the framework's timer queue. When the scheduled time is
reached, the framework gives this object to the next available
service thread by placing this object on the service queue.
Field Summary |
private com.ibm.etill.framework.cassette.BatchCloseRequest |
objRequest
This TimeOfDayWorkItem attribute contains a batch close request
for the batch that is to be automatically closed at a specified
time of day. |
Constructor Summary |
LdbCardBatch.TimeOfDayWorkItem(com.ibm.etill.framework.cassette.BatchCloseRequest argRequest,
com.ibm.etill.framework.cassette.Cassette argCassette)
This constructor
initalizes a TimeOfDayWorkItem
constructs a new TimeableTransaction that references this
TimeOfDayWorkItem as well as the time when it is to be triggerd
adds the TimeableTransaction to the frameworks timer queue. |
Method Summary |
private void |
addToTimerQueue(int argMinutesAfterMidnight)
This method schedules this work item by creating a new
TimeableTransaction that references this object as well as the
time when it is to be triggered and adding the
TimeableTransaction to the framework's timer queue. |
void |
doYourWork()
This method is called by the framework service thread to perform
the work assigned to this work item. |
private void |
scheduleAutoClose(LdbCardBatch argCassetteBatch)
This method is used to schedule an automatic batch close. |
objRequest
private com.ibm.etill.framework.cassette.BatchCloseRequest objRequest
- This TimeOfDayWorkItem attribute contains a batch close request
for the batch that is to be automatically closed at a specified
time of day. It is used in two ways. It is used by the
parent class to determine what framework locks must be obtained
by the thread before it is safe to call the doYourWork()
method. It is also used by this object to obtain references
to the framework and cassette objects needed to perform
the close request.
LdbCardBatch.TimeOfDayWorkItem
public LdbCardBatch.TimeOfDayWorkItem(com.ibm.etill.framework.cassette.BatchCloseRequest argRequest,
com.ibm.etill.framework.cassette.Cassette argCassette)
throws com.ibm.etill.framework.payapi.ETillAbortOperation
- This constructor
- initalizes a TimeOfDayWorkItem
- constructs a new TimeableTransaction that references this
TimeOfDayWorkItem as well as the time when it is to be triggerd
- adds the TimeableTransaction to the frameworks timer queue.
- Parameters:
argRequest
- - a BatchCloseRequest for the batch
to be closed automatically. (NOTE: This batch close request
cannot be used to actually close the batch because it does
not contain locks for all the orders that are added to
the batch after it is constructed and before the batch close
is actually performed.)argCassette
- - the cassette that owns the batch.- Throws:
- ETillAbortOperation - - any failure results in this
exception.
addToTimerQueue
private void addToTimerQueue(int argMinutesAfterMidnight)
- This method schedules this work item by creating a new
TimeableTransaction that references this object as well as the
time when it is to be triggered and adding the
TimeableTransaction to the framework's timer queue.
- Parameters:
argMinutesAfterMidnight
- - the minutes after midnight
when the automatic batch close is to be performed.
doYourWork
public void doYourWork()
throws com.ibm.etill.framework.payapi.ETillAbortOperation
- This method is called by the framework service thread to perform
the work assigned to this work item. Before calling this
method, the service thread will obtain all the required locks.
The list of required locks is determined by the Request object
(in this case a BatchCloseRequest object) that was specified
when this work item was constructed. See the framework Javadoc
for the BatchCloseRequest object to see what locks are obtained.
- Throws:
- ETillAbortOperation - - any failure results in this
exception.
scheduleAutoClose
private void scheduleAutoClose(LdbCardBatch argCassetteBatch)
throws com.ibm.etill.framework.payapi.ETillAbortOperation
- This method is used to schedule an automatic batch close. The
BatchClose request used to construct this cassette work item
guarantees that the write lock of the framework Account object
has been acquired before this workitem was given control.
This guarantees that no Deposit, DepositReversal, Refund, or
RefundReversal commands (in other words, the commands that
could change the contents of a batch) can race in at this
point. That is why no synchronization is necessary to
schedule the automatic close.
Note: The automatic batch close cannot be performed on this
thread because this thread does not have all the required
locks. Most likely, payments and credits have been added to
the batch since this object's BatchCloseRequest was constructed.
Therefore, this object's BatchCloseRequest does not contain
references to the order object locks for these additional
payments and credits. A new BatchCloseRequest (one that
represents the current state of the batch) must be constructed
and sent to a service thread where the proper locks can be
obtained before performing the close.
- Parameters:
argCassetteBatch
- - the batch to be closed.- Throws:
- ETillAbortOperation - - any failure results in this
exception.