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 for
TxInvocationContext
.- Since:
- 4.0
- Author:
- Mircea.Markus@jboss.com, Galder ZamarreƱo, Pedro Ruivo
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractTxInvocationContext
(T cacheTransaction, Address origin) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addAffectedKey
(Object key) final void
addAllAffectedKeys
(Collection<?> keys) Registers a new participant with the transaction.final void
addLockedKey
(Object key) Tracks the given key as locked by this invocation context.final void
Returns the set of keys that are affected by this transaction.final T
final GlobalTransaction
Returns the id of the transaction associated with the current call.Returns the set of keys that are locked for writing.Returns the in behalf of which locks will be acquired.final Map
<Object, CacheEntry> Retrieves a map of entries looked up within the current scope.final List
<org.infinispan.commands.write.WriteCommand> Returns the modifications performed in the scope of the current transaction.final boolean
Checks if there are modifications performed within the tx's scope.final boolean
Returns true if this call is performed in the context of an transaction, false otherwise.final CacheEntry
lookupEntry
(Object key) Retrieves an entry from the collection of looked up entries in the current scope.final void
putLookedUpEntry
(Object key, CacheEntry e) Puts an entry in the registry of looked up entries in the current scope.final void
void
setLockOwner
(Object lockOwner) Sets the object to be used by lock owner.Methods inherited from class org.infinispan.context.impl.AbstractInvocationContext
clone, getOrigin, hasLockedKey, isEntryRemovedInContext, isOriginLocal, publisher
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, publisher, removeLookedUpEntries
Methods inherited from interface org.infinispan.context.InvocationContext
addLockedKeys, clone, getOrigin, hasLockedKey, isEntryRemovedInContext, isOriginLocal
Methods inherited from interface org.infinispan.context.impl.TxInvocationContext
getTransaction, isImplicitTransaction, isTransactionValid
-
Constructor Details
-
AbstractTxInvocationContext
-
-
Method Details
-
getLockOwner
Description copied from interface:InvocationContext
Returns the in behalf of which locks will be acquired.- Specified by:
getLockOwner
in interfaceInvocationContext
-
setLockOwner
Description copied from interface:InvocationContext
Sets the object to be used by lock owner.- Specified by:
setLockOwner
in interfaceInvocationContext
-
getLockedKeys
Description copied from interface:InvocationContext
Returns the set of keys that are locked for writing.- Specified by:
getLockedKeys
in interfaceInvocationContext
-
addLockedKey
Description copied from interface:InvocationContext
Tracks the given key as locked by this invocation context.- Specified by:
addLockedKey
in interfaceInvocationContext
-
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
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
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
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
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
Description copied from interface:TxInvocationContext
Registers a new participant with the transaction.- Specified by:
addAllAffectedKeys
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
addAffectedKey
- Specified by:
addAffectedKey
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-
putLookedUpEntry
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
- 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
- Specified by:
getCacheTransaction
in interfaceTxInvocationContext<T extends AbstractCacheTransaction>
-