org.prevayler.util.memento
Class MementoManagerCommand

java.lang.Object
  extended by org.prevayler.util.memento.MementoManagerCommand
All Implemented Interfaces:
Serializable, TransactionWithQuery<Bank,Account>, MementoCollector

public class MementoManagerCommand
extends Object
implements TransactionWithQuery<Bank,Account>, MementoCollector

This transaction manages the mementos and restores them in case of a failure.

Version:
2.0
Author:
Johan Stuyts
See Also:
Serialized Form

Constructor Summary
MementoManagerCommand(MementoTransaction transaction)
          Create a memento manager transaction.
 
Method Summary
 void addMemento(Memento memento)
          Add a memento to the memento collection.
 Account executeAndQuery(Bank prevalentSystem, Date timestamp)
          Executes this transaction on the received system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MementoManagerCommand

public MementoManagerCommand(MementoTransaction transaction)
Create a memento manager transaction.

Parameters:
transaction - The actual transaction to execute.
Method Detail

executeAndQuery

public Account executeAndQuery(Bank prevalentSystem,
                               Date timestamp)
                        throws Exception
Executes this transaction on the received system. See org.prevayler.demos for examples. The returned object has to be Serializable in preparation for future versions of Prevayler that will provide fault-tolerance through system replicas. This method executes the actual transaction and restores the mementos if the execution fails.

Specified by:
executeAndQuery in interface TransactionWithQuery<Bank,Account>
Parameters:
prevalentSystem - The prevalent system on which to execute the transaction.
timestamp - The time at which this TransactionWithQuery is being executed. Every Transaction executes completely within a single moment in time. Logically, a Prevalent System's time does not pass during the execution of a Transaction.
Returns:
The object returned by the execution of this transaction. Most commands simply return null.
Throws:
Exception

addMemento

public void addMemento(Memento memento)
Add a memento to the memento collection. A memento will only be added if a memento with the same owner does not exist.

Specified by:
addMemento in interface MementoCollector
Parameters:
memento - The memento to add.


Copyright © 2001-2013. All Rights Reserved.