org.jboss.cache.transaction
Class AbstractTransactionContext

java.lang.Object
  extended by org.jboss.cache.transaction.AbstractTransactionContext
All Implemented Interfaces:
TransactionContext
Direct Known Subclasses:
MVCCTransactionContext, PessimisticTransactionContext

public abstract class AbstractTransactionContext
extends Object
implements TransactionContext

An abstract transaction context


Constructor Summary
AbstractTransactionContext(Transaction tx)
           
 
Method Summary
 void addAllLocks(List newLocks)
          Adds a List of locks to the currently maintained collection of locks acquired.
 void addDummyNodeCreatedByCacheLoader(Fqn fqn)
          Adds an Fqn to the list of uninitialized nodes created by the cache loader.
 void addLocalModification(WriteCommand command)
          Adds a modification to the local modification list.
 void addLock(Object lock)
          Adds a lock to the currently maintained collection of locks acquired.
 void addModification(WriteCommand command)
          Adds a modification to the modification list.
 void addRemovedNode(Fqn fqn)
          Adds the node that has been removed in the scope of the current transaction.
 void clearLocks()
          Clears all locks from the currently maintained collection of locks acquired.
 List<Fqn> getDummyNodesCreatedByCacheLoader()
           
 List<WriteCommand> getLocalModifications()
          Returns all modifications that have been invoked with the LOCAL cache mode option.
 List getLocks()
          Returns an immutable, defensive copy of the List of locks currently maintained for the transaction.
 List<WriteCommand> getModifications()
          Returns all modifications.
 Option getOption()
          Retrieves a transaction scope option override
 OrderedSynchronizationHandler getOrderedSynchronizationHandler()
           
 List<Fqn> getRemovedNodes()
          Gets the list of removed nodes.
 Transaction getTransaction()
          Returns a local transaction associated with this context.
 boolean hasAnyModifications()
           
 boolean hasLocalModifications()
           
 boolean hasLock(Object lock)
          Most code could not use this method directly, but use InvocationContext.hasLock(Object) ()} instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
 boolean hasModifications()
           
 boolean isForceAsyncReplication()
          Gets the value of the forceAsyncReplication flag.
 boolean isForceSyncReplication()
          Gets the value of the forceSyncReplication flag.
 void removeLock(Object lock)
          Removes a lock from the currently maintained collection of locks acquired.
 void reset()
          Cleans up internal state, freeing up references.
 void setForceAsyncReplication(boolean forceAsyncReplication)
          Sets the value of the forceAsyncReplication flag.
 void setForceSyncReplication(boolean forceSyncReplication)
          Sets the value of the forceSyncReplication flag.
 void setOption(Option o)
          Sets a transaction-scope option override
 void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
          Associates an ordered sync handler with this transaction.
 void setTransaction(Transaction tx)
          Sets the local transaction to be associated with this transaction context.
 String toString()
          Returns debug information about this transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTransactionContext

public AbstractTransactionContext(Transaction tx)
                           throws SystemException,
                                  RollbackException
Throws:
SystemException
RollbackException
Method Detail

addModification

public void addModification(WriteCommand command)
Description copied from interface: TransactionContext
Adds a modification to the modification list.

Specified by:
addModification in interface TransactionContext
Parameters:
command - modification

getModifications

public List<WriteCommand> getModifications()
Description copied from interface: TransactionContext
Returns all modifications. If there are no modifications in this transaction this method will return an empty list.

Specified by:
getModifications in interface TransactionContext
Returns:
list of modifications.

addLocalModification

public void addLocalModification(WriteCommand command)
Description copied from interface: TransactionContext
Adds a modification to the local modification list.

Specified by:
addLocalModification in interface TransactionContext
Parameters:
command - command to add to list. Should not be null.

getLocalModifications

public List<WriteCommand> getLocalModifications()
Description copied from interface: TransactionContext
Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.

Specified by:
getLocalModifications in interface TransactionContext
Returns:
list of LOCAL modifications, or an empty list.

addRemovedNode

public void addRemovedNode(Fqn fqn)
Description copied from interface: TransactionContext
Adds the node that has been removed in the scope of the current transaction.

Specified by:
addRemovedNode in interface TransactionContext
Parameters:
fqn - fqn that has been removed.

getRemovedNodes

public List<Fqn> getRemovedNodes()
Description copied from interface: TransactionContext
Gets the list of removed nodes.

Specified by:
getRemovedNodes in interface TransactionContext
Returns:
list of nodes removed in the current transaction scope. Note that this method will return an empty list if nothing has been removed. The list returned is defensively copied.

setTransaction

public void setTransaction(Transaction tx)
Description copied from interface: TransactionContext
Sets the local transaction to be associated with this transaction context.

Specified by:
setTransaction in interface TransactionContext
Parameters:
tx - JTA transaction to associate with.

getTransaction

public Transaction getTransaction()
Description copied from interface: TransactionContext
Returns a local transaction associated with this context.

Specified by:
getTransaction in interface TransactionContext
Returns:
a JTA transaction

addLock

public void addLock(Object lock)
Description copied from interface: TransactionContext
Adds a lock to the currently maintained collection of locks acquired.

Most code could not use this method directly, but use InvocationContext.addLock(Object) instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqns as locks) as well as legacy Optimistic and Pessimistic Locking schemes (which use NodeLock as locks). Once support for legacy node locking schemes are dropped, this method will be more strongly typed to accept Fqn.

Specified by:
addLock in interface TransactionContext
Parameters:
lock - lock to add
See Also:
InvocationContext.addLock(Object)

removeLock

public void removeLock(Object lock)
Description copied from interface: TransactionContext
Removes a lock from the currently maintained collection of locks acquired.

Most code could not use this method directly, but use InvocationContext.removeLock(Object) instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqns as locks) as well as legacy Optimistic and Pessimistic Locking schemes (which use NodeLock as locks). Once support for legacy node locking schemes are dropped, this method will be more strongly typed to accept Fqn.

Specified by:
removeLock in interface TransactionContext
Parameters:
lock - lock to remove
See Also:
InvocationContext.removeLock(Object)

clearLocks

public void clearLocks()
Description copied from interface: TransactionContext
Clears all locks from the currently maintained collection of locks acquired.

Most code could not use this method directly, but use InvocationContext.clearLocks() instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqns as locks) as well as legacy Optimistic and Pessimistic Locking schemes (which use NodeLock as locks). Once support for legacy node locking schemes are dropped, this method will be more strongly typed to accept Fqn.

Specified by:
clearLocks in interface TransactionContext
See Also:
InvocationContext.clearLocks()

hasLock

public boolean hasLock(Object lock)
Description copied from interface: TransactionContext
Most code could not use this method directly, but use InvocationContext.hasLock(Object) ()} instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Specified by:
hasLock in interface TransactionContext
Parameters:
lock - lock to test
Returns:
true if the lock being tested is already held in the current scope, false otherwise.

addAllLocks

public void addAllLocks(List newLocks)
Description copied from interface: TransactionContext
Adds a List of locks to the currently maintained collection of locks acquired.

Most code could not use this method directly, but use InvocationContext.addAllLocks(java.util.List) instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks) as well as legacy Optimistic and Pessimistic Locking schemes (which use NodeLock as locks). Once support for legacy node locking schemes are dropped, this method will be more strongly typed to accept List.

Specified by:
addAllLocks in interface TransactionContext
Parameters:
newLocks - locks to add
See Also:
InvocationContext.addAllLocks(java.util.List)

getLocks

public List getLocks()
Description copied from interface: TransactionContext
Returns an immutable, defensive copy of the List of locks currently maintained for the transaction.

Most code could not use this method directly, but use InvocationContext.getLocks() instead, which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.

Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks) as well as legacy Optimistic and Pessimistic Locking schemes (which use NodeLock as locks). Once support for legacy node locking schemes are dropped, this method will be more strongly typed to return List.

Specified by:
getLocks in interface TransactionContext
Returns:
locks held in current scope.
See Also:
InvocationContext.getLocks()

isForceAsyncReplication

public boolean isForceAsyncReplication()
Description copied from interface: TransactionContext
Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor when dealing with Cache.putForExternalRead(org.jboss.cache.Fqn,Object,Object) within a transactional context.

Specified by:
isForceAsyncReplication in interface TransactionContext
Returns:
true if the forceAsyncReplication flag is set to true.

setForceAsyncReplication

public void setForceAsyncReplication(boolean forceAsyncReplication)
Description copied from interface: TransactionContext
Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor when dealing with Cache.putForExternalRead(org.jboss.cache.Fqn,Object,Object) within a transactional context. Also used by OptimisticReplicationInterceptor when dealing with Option.setForceAsynchronous(boolean) in a non-transactional context (i.e. with an implicit transaction).

Specified by:
setForceAsyncReplication in interface TransactionContext
Parameters:
forceAsyncReplication - value of forceAsyncReplication

isForceSyncReplication

public boolean isForceSyncReplication()
Description copied from interface: TransactionContext
Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor when dealing with Cache.putForExternalRead(org.jboss.cache.Fqn,Object,Object) within a transactional context.

Specified by:
isForceSyncReplication in interface TransactionContext
Returns:
true if the forceAsyncReplication flag is set to true.

setForceSyncReplication

public void setForceSyncReplication(boolean forceSyncReplication)
Description copied from interface: TransactionContext
Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor when dealing with Cache.putForExternalRead(org.jboss.cache.Fqn,Object,Object) within a transactional context.

Specified by:
setForceSyncReplication in interface TransactionContext
Parameters:
forceSyncReplication - value of forceSyncReplication

toString

public String toString()
Returns debug information about this transaction.

Overrides:
toString in class Object

addDummyNodeCreatedByCacheLoader

public void addDummyNodeCreatedByCacheLoader(Fqn fqn)
Description copied from interface: TransactionContext
Adds an Fqn to the list of uninitialized nodes created by the cache loader.

Specified by:
addDummyNodeCreatedByCacheLoader in interface TransactionContext
Parameters:
fqn - fqn to add. Must not be null.

getDummyNodesCreatedByCacheLoader

public List<Fqn> getDummyNodesCreatedByCacheLoader()
Specified by:
getDummyNodesCreatedByCacheLoader in interface TransactionContext
Returns:
a list of uninitialized nodes created by the cache loader, or an empty list.

setOption

public void setOption(Option o)
Description copied from interface: TransactionContext
Sets a transaction-scope option override

Specified by:
setOption in interface TransactionContext
Parameters:
o - option to set

getOption

public Option getOption()
Description copied from interface: TransactionContext
Retrieves a transaction scope option override

Specified by:
getOption in interface TransactionContext
Returns:
option

getOrderedSynchronizationHandler

public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
Specified by:
getOrderedSynchronizationHandler in interface TransactionContext
Returns:
the ordered sync handler associated with this transaction

setOrderedSynchronizationHandler

public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
Description copied from interface: TransactionContext
Associates an ordered sync handler with this transaction.

Specified by:
setOrderedSynchronizationHandler in interface TransactionContext
Parameters:
orderedSynchronizationHandler - to set

hasModifications

public boolean hasModifications()
Specified by:
hasModifications in interface TransactionContext
Returns:
true if modifications were registered.

hasLocalModifications

public boolean hasLocalModifications()
Specified by:
hasLocalModifications in interface TransactionContext
Returns:
true if any modifications have been invoked with cache mode being LOCAL.

hasAnyModifications

public boolean hasAnyModifications()
Specified by:
hasAnyModifications in interface TransactionContext
Returns:
true if either there are modifications or local modifications that are not for replicating.

reset

public void reset()
Description copied from interface: TransactionContext
Cleans up internal state, freeing up references.

Specified by:
reset in interface TransactionContext


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.