Package org.infinispan.context.impl
Class AbstractTxInvocationContext<T extends AbstractCacheTransaction>
- java.lang.Object
-
- org.infinispan.context.impl.AbstractInvocationContext
-
- org.infinispan.context.impl.AbstractTxInvocationContext<T>
-
- All Implemented Interfaces:
Cloneable,EntryLookup,TxInvocationContext<T>,InvocationContext
- Direct Known Subclasses:
LocalTxInvocationContext,RemoteTxInvocationContext
public abstract class AbstractTxInvocationContext<T extends AbstractCacheTransaction> extends AbstractInvocationContext implements TxInvocationContext<T>
Support class forTxInvocationContext.- Since:
- 4.0
- Author:
- Mircea.Markus@jboss.com, Galder ZamarreƱo, Pedro Ruivo
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTxInvocationContext(T cacheTransaction, Address origin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAffectedKey(Object key)voidaddAllAffectedKeys(Collection<?> keys)Registers a new participant with the transaction.voidaddLockedKey(Object key)Tracks the given key as locked by this invocation context.voidclearLockedKeys()Set<Object>getAffectedKeys()Returns the set of keys that are affected by this transaction.TgetCacheTransaction()GlobalTransactiongetGlobalTransaction()Returns the id of the transaction associated with the current call.Set<Object>getLockedKeys()Returns the set of keys that are locked for writing.ObjectgetLockOwner()Returns the in behalf of which locks will be acquired.Map<Object,CacheEntry>getLookedUpEntries()Retrieves a map of entries looked up within the current scope.List<org.infinispan.commands.write.WriteCommand>getModifications()Returns the modifications performed in the scope of the current transaction.booleanhasModifications()Checks if there are modifications performed within the tx's scope.booleanisInTxScope()Returns true if this call is performed in the context of an transaction, false otherwise.CacheEntrylookupEntry(Object key)Retrieves an entry from the collection of looked up entries in the current scope.voidputLookedUpEntry(Object key, CacheEntry e)Puts an entry in the registry of looked up entries in the current scope.voidremoveLookedUpEntry(Object key)voidsetLockOwner(Object lockOwner)Sets the object to be used by lock owner.-
Methods inherited from class org.infinispan.context.impl.AbstractInvocationContext
clone, getClassLoader, getOrigin, hasLockedKey, isEntryRemovedInContext, isOriginLocal, onEntryValueReplaced, setClassLoader
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.context.EntryLookup
forEachEntry, forEachValue, lookedUpEntriesCount, removeLookedUpEntries
-
Methods inherited from interface org.infinispan.context.InvocationContext
clone, getClassLoader, getOrigin, hasLockedKey, isEntryRemovedInContext, isOriginLocal, replaceValue, setClassLoader
-
Methods inherited from interface org.infinispan.context.impl.TxInvocationContext
getTransaction, isImplicitTransaction, isTransactionValid
-
-
-
-
Method Detail
-
getLockOwner
public Object getLockOwner()
Description copied from interface:InvocationContextReturns the in behalf of which locks will be acquired.- Specified by:
getLockOwnerin interfaceInvocationContext
-
setLockOwner
public void setLockOwner(Object lockOwner)
Description copied from interface:InvocationContextSets the object to be used by lock owner.- Specified by:
setLockOwnerin interfaceInvocationContext
-
getLockedKeys
public final Set<Object> getLockedKeys()
Description copied from interface:InvocationContextReturns the set of keys that are locked for writing.- Specified by:
getLockedKeysin interfaceInvocationContext
-
addLockedKey
public final void addLockedKey(Object key)
Description copied from interface:InvocationContextTracks the given key as locked by this invocation context.- Specified by:
addLockedKeyin interfaceInvocationContext
-
getGlobalTransaction
public final GlobalTransaction getGlobalTransaction()
Description copied from interface:TxInvocationContextReturns the id of the transaction associated with the current call.- Specified by:
getGlobalTransactionin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
hasModifications
public final boolean hasModifications()
Description copied from interface:TxInvocationContextChecks if there are modifications performed within the tx's scope. Any modifications having Flag.CACHE_MODE_LOCAL are ignored.- Specified by:
hasModificationsin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
getModifications
public final List<org.infinispan.commands.write.WriteCommand> getModifications()
Description copied from interface:TxInvocationContextReturns the modifications performed in the scope of the current transaction. Any modifications having Flag.CACHE_MODE_LOCAL are ignored. The returned list can be null.- Specified by:
getModificationsin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
lookupEntry
public final CacheEntry lookupEntry(Object key)
Description copied from interface:EntryLookupRetrieves an entry from the collection of looked up entries in the current scope.- Specified by:
lookupEntryin interfaceEntryLookup- Parameters:
key- key to look up- Returns:
- an entry, or null if it cannot be found.
-
getLookedUpEntries
public final Map<Object,CacheEntry> getLookedUpEntries()
Description copied from interface:EntryLookupRetrieves a map of entries looked up within the current scope. Note: The key inside the CacheEntry may benullif the key does not exist in the cache.- Specified by:
getLookedUpEntriesin interfaceEntryLookup- Returns:
- a map of looked up entries.
-
getAffectedKeys
public final Set<Object> getAffectedKeys()
Description copied from interface:TxInvocationContextReturns the set of keys that are affected by this transaction. Used to generate appropriate recipient groups for cluster-wide prepare and commit calls.- Specified by:
getAffectedKeysin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
addAllAffectedKeys
public final void addAllAffectedKeys(Collection<?> keys)
Description copied from interface:TxInvocationContextRegisters a new participant with the transaction.- Specified by:
addAllAffectedKeysin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
addAffectedKey
public final void addAffectedKey(Object key)
- Specified by:
addAffectedKeyin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
putLookedUpEntry
public final void putLookedUpEntry(Object key, CacheEntry e)
Description copied from interface:EntryLookupPuts an entry in the registry of looked up entries in the current scope.- Specified by:
putLookedUpEntryin interfaceEntryLookup- Parameters:
key- key to storee- entry to store
-
removeLookedUpEntry
public final void removeLookedUpEntry(Object key)
- Specified by:
removeLookedUpEntryin interfaceEntryLookup
-
isInTxScope
public final boolean isInTxScope()
Description copied from interface:InvocationContextReturns true if this call is performed in the context of an transaction, false otherwise.- Specified by:
isInTxScopein interfaceInvocationContext
-
clearLockedKeys
public final void clearLockedKeys()
- Specified by:
clearLockedKeysin interfaceInvocationContext
-
getCacheTransaction
public final T getCacheTransaction()
- Specified by:
getCacheTransactionin interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
-