org.openanzo.model.transaction.impl
Class TransactionQueue

java.lang.Object
  extended by org.openanzo.model.transaction.impl.TransactionQueue
All Implemented Interfaces:
ITransactionQueue
Direct Known Subclasses:
RDBPersistedTransactionQueue

public class TransactionQueue
extends java.lang.Object
implements ITransactionQueue

Standard implementation of ITransactionQueue

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
TransactionQueue()
          Create new transaction queue
 
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 listener)
          Set the TransactionQueue Events.
 void transactionsCommitted(ITransaction[] transactions, boolean[] updateResults, java.util.List<AnzoException>[] errors)
          Notify the queue that a set of transactions were committed successfully.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionQueue

public TransactionQueue()
Create new transaction queue

Method Detail

setTransactionHandler

public void setTransactionHandler(ITransactionQueueHandler listener)
Description copied from interface: ITransactionQueue
Set the TransactionQueue Events.

Specified by:
setTransactionHandler in interface ITransactionQueue
Parameters:
listener - that handles TransactionQueue events

removeTransactionHandler

public void removeTransactionHandler()
Description copied from interface: ITransactionQueue
Remove the TransactionQueue handler.

Specified by:
removeTransactionHandler in interface ITransactionQueue

addTransactionQueueListener

public void addTransactionQueueListener(ITransactionQueueListener listener)
Description copied from interface: ITransactionQueue
Add a new listener for TransactionQueue Events.

Specified by:
addTransactionQueueListener in interface ITransactionQueue
Parameters:
listener - that handles events

removeTransactionQueueListener

public void removeTransactionQueueListener(ITransactionQueueListener listener)
Description copied from interface: ITransactionQueue
Remove a TransactionQueue listener.

Specified by:
removeTransactionQueueListener in interface ITransactionQueue
Parameters:
listener - that handles events

clear

public void clear()
           throws AnzoException
Description copied from interface: ITransactionQueue
Clear all transactions from the queue and set currentTransaction to null.

Specified by:
clear in interface ITransactionQueue
Throws:
AnzoException - if there was an error clearing the transaction queue

abortCurrentTransaction

public void abortCurrentTransaction()
Description copied from interface: ITransactionQueue
Abort the currentTransaction and set currentTransaction to null;

Specified by:
abortCurrentTransaction in interface ITransactionQueue

getSize

public int getSize()
Description copied from interface: ITransactionQueue
Get the number of transaction in the queue

Specified by:
getSize in interface ITransactionQueue
Returns:
number of transaction in the queue

push

public void push(ITransaction transaction,
                 boolean saveTransaction)
          throws AnzoException
Description copied from interface: ITransactionQueue
Push a transaction onto the queue, this will commit the currentTransaction if not null.

Specified by:
push in interface ITransactionQueue
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

getTransactions

public java.util.List<ITransaction> getTransactions()
Description copied from interface: ITransactionQueue
Get a list containing the transactions in the queue

Specified by:
getTransactions in interface ITransactionQueue
Returns:
a list containing the transactions in the queue

queueCurrentTransaction

public void queueCurrentTransaction()
                             throws AnzoException
Description copied from interface: ITransactionQueue
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.

Specified by:
queueCurrentTransaction in interface ITransactionQueue
Throws:
AnzoException

getCurrentTransaction

public ITransaction getCurrentTransaction(boolean create)
                                   throws AnzoException
Description copied from interface: ITransactionQueue
Get the currentTransaction, creating one if null and create flag is true.

Specified by:
getCurrentTransaction in interface ITransactionQueue
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

transactionsCommitted

public void transactionsCommitted(ITransaction[] transactions,
                                  boolean[] updateResults,
                                  java.util.List<AnzoException>[] errors)
                           throws AnzoException
Description copied from interface: ITransactionQueue
Notify the queue that a set of transactions were committed successfully.

Specified by:
transactionsCommitted in interface ITransactionQueue
Parameters:
transactions - The transaction that were committed.
updateResults - 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.