org.openanzo.model.transaction
Interface ITransactionQueue

All Known Implementing Classes:
RDBPersistedTransactionQueue, TransactionQueue

public interface ITransactionQueue

The ITransactionQueue contains a queue of ITransactions. Events are sent to listeners when actions occur on the queue.

Author:
Joe Betz, Matthew Roy ( mroy@cambridgesemantics.com )

Method Summary
 void abortCurrentTransaction()
          Abort the currentTransaction and set currentTransaction to null;
 void addTransactionQueueListener(ITransactionQueueListener listener)
          Add a new listener for TransactionQueue Events.
 void clear()
          Clear all transactions from the queue and set currentTransaction to null.
 ITransaction getCurrentTransaction(boolean create)
          Get the currentTransaction, creating one if null and create flag is true.
 int getSize()
          Get the number of transaction in the queue
 java.util.List<ITransaction> getTransactions()
          Get a list containing the transactions in the queue
 void push(ITransaction transaction, boolean saveTransaction)
          Push a transaction onto the queue, this will commit the currentTransaction if not null.
 void queueCurrentTransaction()
          Queue the currentTransaction.
 void removeTransactionHandler()
          Remove the TransactionQueue handler.
 void removeTransactionQueueListener(ITransactionQueueListener listener)
          Remove a TransactionQueue listener.
 void setTransactionHandler(ITransactionQueueHandler handler)
          Set the TransactionQueue Events.
 void transactionsCommitted(ITransaction[] transactions, boolean[] commitResults, java.util.List<AnzoException>[] errors)
          Notify the queue that a set of transactions were committed successfully.
 

Method Detail

abortCurrentTransaction

void abortCurrentTransaction()
Abort the currentTransaction and set currentTransaction to null;


clear

void clear()
           throws AnzoException
Clear all transactions from the queue and set currentTransaction to null.

Throws:
AnzoException - if there was an error clearing the transaction queue

getSize

int getSize()
Get the number of transaction in the queue

Returns:
number of transaction in the queue

getTransactions

java.util.List<ITransaction> getTransactions()
Get a list containing the transactions in the queue

Returns:
a list containing the transactions in the queue

push

void push(ITransaction transaction,
          boolean saveTransaction)
          throws AnzoException
Push a transaction onto the queue, this will commit the currentTransaction if not null.

Parameters:
transaction - Transaction to push onto queue.
saveTransaction - Whether this transaction needs to be persisted when added. If loading persisted transactions, they might only need to added, and not saved.
Throws:
AnzoException

queueCurrentTransaction

void queueCurrentTransaction()
                             throws AnzoException
Queue the currentTransaction. This action will push the currentTransaction onto the queue and fire a TransactionQueuedEvent. No further adds or removes should be done on this transaction.

Throws:
AnzoException

getCurrentTransaction

ITransaction getCurrentTransaction(boolean create)
                                   throws AnzoException
Get the currentTransaction, creating one if null and create flag is true.

Parameters:
create - Whether to create a new transaction if currentTransaction is null.
Returns:
The currentTransaction
Throws:
AnzoException - if there was an error fetching or creating the current transaction

setTransactionHandler

void setTransactionHandler(ITransactionQueueHandler handler)
Set the TransactionQueue Events.

Parameters:
handler - that handles TransactionQueue events

removeTransactionHandler

void removeTransactionHandler()
Remove the TransactionQueue handler.


addTransactionQueueListener

void addTransactionQueueListener(ITransactionQueueListener listener)
Add a new listener for TransactionQueue Events.

Parameters:
listener - that handles events

removeTransactionQueueListener

void removeTransactionQueueListener(ITransactionQueueListener listener)
Remove a TransactionQueue listener.

Parameters:
listener - that handles events

transactionsCommitted

void transactionsCommitted(ITransaction[] transactions,
                           boolean[] commitResults,
                           java.util.List<AnzoException>[] errors)
                           throws AnzoException
Notify the queue that a set of transactions were committed successfully.

Parameters:
transactions - The transaction that were committed.
commitResults - Array of booleans signifying if the corresponding transaction was committed successfully
errors - Array of errors for the corresponding transaction if transaction failed to commit successfully
Throws:
AnzoException - if there was an error processing the committed transactions


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.