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 protected
AbstractTxInvocationContext(T cacheTransaction, Address origin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAffectedKey(Object key)
void
addAllAffectedKeys(Collection<?> keys)
Registers a new participant with the transaction.void
addLockedKey(Object key)
Tracks the given key as locked by this invocation context.void
clearLockedKeys()
Set<Object>
getAffectedKeys()
Returns the set of keys that are affected by this transaction.T
getCacheTransaction()
GlobalTransaction
getGlobalTransaction()
Returns the id of the transaction associated with the current call.Set<Object>
getLockedKeys()
Returns the set of keys that are locked for writing.Object
getLockOwner()
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.boolean
hasModifications()
Checks if there are modifications performed within the tx's scope.boolean
isInTxScope()
Returns true if this call is performed in the context of an transaction, false otherwise.CacheEntry
lookupEntry(Object key)
Retrieves an entry from the collection of looked up entries in the current scope.void
putLookedUpEntry(Object key, CacheEntry e)
Puts an entry in the registry of looked up entries in the current scope.void
removeLookedUpEntry(Object key)
void
setLockOwner(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:InvocationContext
Returns the in behalf of which locks will be acquired.- Specified by:
getLockOwner
in interfaceInvocationContext
-
setLockOwner
public void setLockOwner(Object lockOwner)
Description copied from interface:InvocationContext
Sets the object to be used by lock owner.- Specified by:
setLockOwner
in interfaceInvocationContext
-
getLockedKeys
public final Set<Object> getLockedKeys()
Description copied from interface:InvocationContext
Returns the set of keys that are locked for writing.- Specified by:
getLockedKeys
in interfaceInvocationContext
-
addLockedKey
public final void addLockedKey(Object key)
Description copied from interface:InvocationContext
Tracks the given key as locked by this invocation context.- Specified by:
addLockedKey
in interfaceInvocationContext
-
getGlobalTransaction
public final GlobalTransaction getGlobalTransaction()
Description copied from interface:TxInvocationContext
Returns the id of the transaction associated with the current call.- Specified by:
getGlobalTransaction
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
hasModifications
public final boolean hasModifications()
Description copied from interface:TxInvocationContext
Checks if there are modifications performed within the tx's scope. Any modifications having Flag.CACHE_MODE_LOCAL are ignored.- Specified by:
hasModifications
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
getModifications
public final List<org.infinispan.commands.write.WriteCommand> getModifications()
Description copied from interface:TxInvocationContext
Returns 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:
getModifications
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
lookupEntry
public final CacheEntry lookupEntry(Object key)
Description copied from interface:EntryLookup
Retrieves an entry from the collection of looked up entries in the current scope.- Specified by:
lookupEntry
in 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:EntryLookup
Retrieves a map of entries looked up within the current scope. Note: The key inside the CacheEntry may benull
if the key does not exist in the cache.- Specified by:
getLookedUpEntries
in interfaceEntryLookup
- Returns:
- a map of looked up entries.
-
getAffectedKeys
public final Set<Object> getAffectedKeys()
Description copied from interface:TxInvocationContext
Returns 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:
getAffectedKeys
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
addAllAffectedKeys
public final void addAllAffectedKeys(Collection<?> keys)
Description copied from interface:TxInvocationContext
Registers a new participant with the transaction.- Specified by:
addAllAffectedKeys
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
addAffectedKey
public final void addAffectedKey(Object key)
- Specified by:
addAffectedKey
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
putLookedUpEntry
public final void putLookedUpEntry(Object key, CacheEntry e)
Description copied from interface:EntryLookup
Puts an entry in the registry of looked up entries in the current scope.- Specified by:
putLookedUpEntry
in interfaceEntryLookup
- Parameters:
key
- key to storee
- entry to store
-
removeLookedUpEntry
public final void removeLookedUpEntry(Object key)
- Specified by:
removeLookedUpEntry
in interfaceEntryLookup
-
isInTxScope
public final boolean isInTxScope()
Description copied from interface:InvocationContext
Returns true if this call is performed in the context of an transaction, false otherwise.- Specified by:
isInTxScope
in interfaceInvocationContext
-
clearLockedKeys
public final void clearLockedKeys()
- Specified by:
clearLockedKeys
in interfaceInvocationContext
-
getCacheTransaction
public final T getCacheTransaction()
- Specified by:
getCacheTransaction
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
-