org.infinispan.context
Class TransactionContextImpl

java.lang.Object
  extended by org.infinispan.context.AbstractContext
      extended by org.infinispan.context.TransactionContextImpl
All Implemented Interfaces:
EntryLookup, FlagContainer, TransactionContext
Direct Known Subclasses:
DistTransactionContextImpl

public class TransactionContextImpl
extends AbstractContext
implements TransactionContext

A transaction context specially geared to dealing with MVCC.

Since:
4.0
Author:
Manik Surtani (manik@jboss.org)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.infinispan.context.AbstractContext
AbstractContext.ContextFlags
 
Field Summary
 
Fields inherited from class org.infinispan.context.AbstractContext
contextFlags, flags, lookedUpEntries
 
Constructor Summary
TransactionContextImpl(Transaction tx)
           
 
Method Summary
 void addDummyEntryCreatedByCacheLoader(Object key)
          Adds a key to the list of uninitialized entry keys created by the cache loader.
 void addLocalModification(WriteCommand command)
          Adds a modification to the local modification list.
 void addModification(WriteCommand command)
          Adds a modification to the modification list.
 void addRemovedEntry(Object key)
          Adds the key that has been removed in the scope of the current transaction.
 void addTransactionParticipants(Collection<Address> addresses)
          Adds a transaction participant.
 boolean equals(Object o)
           
 List<Object> getDummyEntriesCreatedByCacheLoader()
           
 GlobalTransaction getGobalTransaction()
           
 List<WriteCommand> getLocalModifications()
          Returns all modifications that have been invoked with the LOCAL cache mode option.
protected  int getLockSetSize()
           
 List<WriteCommand> getModifications()
          Returns all modifications.
 List<Object> getRemovedEntries()
          Gets the list of removed keys.
 Transaction getTransaction()
          Returns a local transaction associated with this context.
 Set<Address> getTransactionParticipants()
          Retrieves a set of Addresses of caches participating in a given transaction for a specific cache.
 boolean hasAnyModifications()
           
 int hashCode()
           
 boolean hasLocalModifications()
           
 boolean hasModifications()
           
 boolean isForceAsyncReplication()
          Gets the value of the forceAsyncReplication flag.
 boolean isForceSyncReplication()
          Gets the value of the forceSyncReplication flag.
 void putLookedUpEntries(Map<Object,CacheEntry> entries)
           
 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 setGlobalTransaction(GlobalTransaction gtx)
           
 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 org.infinispan.context.AbstractContext
clearLookedUpEntries, copyInto, getFlags, getLookedUpEntries, hasFlag, hasLockedKey, isContainsLocks, isContainsModifications, isContextFlagSet, isFlagsUninitialized, lookupEntry, putLookedUpEntry, removeLookedUpEntry, resetFlags, setContainsLocks, setContainsModifications, setContextFlag, setContextFlag, setFlags, setFlags, unsetContextFlag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.infinispan.context.EntryLookup
clearLookedUpEntries, getLookedUpEntries, hasLockedKey, isContainsLocks, isContainsModifications, lookupEntry, putLookedUpEntry, removeLookedUpEntry, setContainsLocks, setContainsModifications
 
Methods inherited from interface org.infinispan.context.FlagContainer
getFlags, hasFlag, isFlagsUninitialized, resetFlags, setFlags, setFlags
 

Constructor Detail

TransactionContextImpl

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

getLockSetSize

protected final int getLockSetSize()
Specified by:
getLockSetSize in class AbstractContext

reset

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

Specified by:
reset in interface TransactionContext
Overrides:
reset in class AbstractContext

getGobalTransaction

public GlobalTransaction getGobalTransaction()
Specified by:
getGobalTransaction in interface TransactionContext

getTransactionParticipants

public Set<Address> getTransactionParticipants()
Description copied from interface: TransactionContext
Retrieves a set of Addresses of caches participating in a given transaction for a specific cache. Returns null if the participation includes all caches in the cluster (e.g., you are using replication, invalidation or local mode).

Specified by:
getTransactionParticipants in interface TransactionContext
Returns:
a set of cache addresses

addTransactionParticipants

public void addTransactionParticipants(Collection<Address> addresses)
Description copied from interface: TransactionContext
Adds a transaction participant. This has no effect unless the cache mode used is DIST.

Specified by:
addTransactionParticipants in interface TransactionContext
Parameters:
addresses - address to add

putLookedUpEntries

public void putLookedUpEntries(Map<Object,CacheEntry> entries)
Specified by:
putLookedUpEntries in interface EntryLookup
Overrides:
putLookedUpEntries in class AbstractContext

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.

addRemovedEntry

public void addRemovedEntry(Object key)
Description copied from interface: TransactionContext
Adds the key that has been removed in the scope of the current transaction.

Specified by:
addRemovedEntry in interface TransactionContext
Parameters:
key - key that has been removed.

getRemovedEntries

public List<Object> getRemovedEntries()
Description copied from interface: TransactionContext
Gets the list of removed keys.

Specified by:
getRemovedEntries in interface TransactionContext
Returns:
list of keys of entries 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.

setGlobalTransaction

public void setGlobalTransaction(GlobalTransaction gtx)
Specified by:
setGlobalTransaction in interface TransactionContext

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

isForceAsyncReplication

public boolean isForceAsyncReplication()
Description copied from interface: TransactionContext
Gets the value of the forceAsyncReplication flag.

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.

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.

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.

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

addDummyEntryCreatedByCacheLoader

public void addDummyEntryCreatedByCacheLoader(Object key)
Description copied from interface: TransactionContext
Adds a key to the list of uninitialized entry keys created by the cache loader.

Specified by:
addDummyEntryCreatedByCacheLoader in interface TransactionContext
Parameters:
key - key to add. Must not be null.

getDummyEntriesCreatedByCacheLoader

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

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.

equals

public boolean equals(Object o)
Overrides:
equals in class AbstractContext

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractContext


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