storage.memory
Class memTxn

java.lang.Object
  extended bystorage.memory.memTxn
All Implemented Interfaces:
Txn, TxnBuilder

public class memTxn
extends java.lang.Object
implements Txn, TxnBuilder

A class for creating and managing transactions. Once it is created, a memTxn can then be used to compose transactions using the addOp() method. If the memTxn is invertable, then the inverse transaction will automatically be constructed as the transaction is being composed.


Field Summary
protected  java.util.LinkedList ops
           
 
Constructor Summary
protected memTxn(Repository repo, boolean invertable)
          Create a memTxn which is optionally constructing its own inverse.
 
Method Summary
 TxnOp addOp(Node subj, Operator op)
          Create a TxnOp and add it to the list of TxnOps in this Txn.
 Attribution attribution()
          Who performed the transaction and when?
 boolean commit()
          Commit the currently accumulated Txn.
 boolean committed()
          Has this transaction been committed?
static TxnBuilder create(Repository repo)
          Create a memTxn to accumulate TxnOps.
static memTxn create(TxnManager provider)
          Create a memTxn to accumulate TxnOps.
static TxnBuilder createInvertable(Repository repo)
          Create a memTxn to accumulate TxnOps and automatically construct its inverse.
 Txn inverse()
          A transaction that inverts the actions of this one.
 java.util.List ops()
          The subjects and operations performed by this transaction.
 Repository repository()
          The Repository that this transaction was performed against.
 boolean resolved()
          Has this transaction been resolved?
 storage.framework.TxnResolver resolver()
          Creates a TxnResolver interface for this Txn.
 boolean retractOp(TxnOp op)
          Retract a TxnOp from this Txn.
 java.util.List subjectList(Node subject)
          The List of all TxnOp instances that operate on the given subject.
 java.util.Set subjects()
          A Set of the subjects that are contained in this Txn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ops

protected java.util.LinkedList ops
Constructor Detail

memTxn

protected memTxn(Repository repo,
                 boolean invertable)
Create a memTxn which is optionally constructing its own inverse.

Parameters:
repo - the Repository holding this transaction
invertable - whether or not to construct an inverse
Method Detail

create

public static TxnBuilder create(Repository repo)
Create a memTxn to accumulate TxnOps.


create

public static memTxn create(TxnManager provider)
Create a memTxn to accumulate TxnOps.


createInvertable

public static TxnBuilder createInvertable(Repository repo)
Create a memTxn to accumulate TxnOps and automatically construct its inverse.


repository

public Repository repository()
Description copied from interface: Txn
The Repository that this transaction was performed against.

Specified by:
repository in interface Txn

attribution

public Attribution attribution()
Description copied from interface: Txn
Who performed the transaction and when?

Specified by:
attribution in interface Txn

ops

public java.util.List ops()
Description copied from interface: Txn
The subjects and operations performed by this transaction. This value cannot be examined until the transaction is committed.

Specified by:
ops in interface Txn

subjects

public java.util.Set subjects()
Description copied from interface: Txn
A Set of the subjects that are contained in this Txn. Elements of this Set are Nodes in the Repository. Using these elements as indices into {#subjectList(Node)} will iterate over all {#ops()}.

Specified by:
subjects in interface Txn
Returns:
a Set of the Nodes that are modified by this transaction

addOp

public TxnOp addOp(Node subj,
                   Operator op)
Description copied from interface: TxnBuilder
Create a TxnOp and add it to the list of TxnOps in this Txn.

Specified by:
addOp in interface TxnBuilder
Parameters:
subj - the Node that is operated on by this TxnOp
op - the Operator that modifies/creates the subj Node
Returns:
a new TxnOp that records this Operator

retractOp

public boolean retractOp(TxnOp op)
Description copied from interface: TxnBuilder
Retract a TxnOp from this Txn. Fails if the TxnOp was not produced by and addOp on this TxnBuilder.

Specified by:
retractOp in interface TxnBuilder
Parameters:
op - the TxnOp to be retracted
Returns:
true if successful

subjectList

public java.util.List subjectList(Node subject)
The List of all TxnOp instances that operate on the given subject.

Specified by:
subjectList in interface Txn

commit

public boolean commit()
Description copied from interface: TxnBuilder
Commit the currently accumulated Txn.

Specified by:
commit in interface TxnBuilder
Returns:
true if we are successfully able to commit.

inverse

public final Txn inverse()
Description copied from interface: Txn
A transaction that inverts the actions of this one.

Specified by:
inverse in interface Txn

committed

public boolean committed()
Description copied from interface: Txn
Has this transaction been committed?

In other words is it final, or still being accumulated?

Specified by:
committed in interface Txn

resolved

public boolean resolved()
Description copied from interface: Txn
Has this transaction been resolved?

Are its results reflected in the persistent backing store?

Specified by:
resolved in interface Txn

resolver

public storage.framework.TxnResolver resolver()
Creates a TxnResolver interface for this Txn.

Returns:
a TxnResolver interface for this Txn