public abstract class InvocationContext extends Object
TransactionContext
if one is in scope.
Note that prior to 3.0.0, InvocationContext was a concrete class and not an abstract one.
TransactionContext
Modifier and Type | Field and Description |
---|---|
protected LinkedHashSet |
invocationLocks
LinkedHashSet of locks acquired by the invocation.
|
protected TransactionContext |
transactionContext |
Constructor and Description |
---|
InvocationContext() |
Modifier and Type | Method and Description |
---|---|
void |
addAllLocks(List locks)
Adds a List of locks to the currently maintained collection of locks acquired.
|
void |
addFqnLoaded(Fqn fqn)
Adds an Fqn to the set of Fqns loaded by the cache loader interceptor.
|
void |
addLock(Object lock)
Adds a lock to the currently maintained collection of locks acquired.
|
void |
clearLocks()
Clears all locks from the currently maintained collection of locks acquired.
|
abstract void |
clearLookedUpNodes()
Clears the registry of looked up nodes.
|
abstract InvocationContext |
copy()
This is a "copy-factory-method" that should be used whenever a clone of this class is needed.
|
protected void |
doCopy(InvocationContext copy) |
boolean |
equals(Object o) |
VisitableCommand |
getCommand()
Deprecated.
|
Set<Fqn> |
getFqnsLoaded() |
GlobalTransaction |
getGlobalTransaction()
Retrieves the global transaction associated with this invocation
|
long |
getLockAcquisitionTimeout(long timeout)
If the lock acquisition timeout is overridden for current call using an option, then return that one.
|
List |
getLocks()
Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
|
abstract Map<Fqn,NodeSPI> |
getLookedUpNodes()
Retrieves a map of nodes looked up within the current invocation's scope.
|
MethodCall |
getMethodCall()
Deprecated.
|
Option |
getOptionOverrides()
Retrieves the option overrides associated with this invocation
|
Transaction |
getTransaction()
Retrieves the transaction associated with this invocation
|
TransactionContext |
getTransactionContext() |
int |
hashCode() |
boolean |
hasLock(Object lock)
Note that if a transaction is in scope, implementations should test this lock from on
TransactionContext . |
boolean |
isBypassUnmarshalling() |
boolean |
isLocalRollbackOnly() |
boolean |
isLockingSuppressed() |
boolean |
isOptionsUninitialised() |
boolean |
isOriginLocal()
Tests if this invocation originated locally or from a remote cache.
|
boolean |
isValidTransaction() |
abstract NodeSPI |
lookUpNode(Fqn fqn)
Retrieves a node from the registry of looked up nodes in the current scope.
|
abstract void |
putLookedUpNode(Fqn f,
NodeSPI n)
Puts an entry in the registry of looked up nodes in the current scope.
|
abstract void |
putLookedUpNodes(Map<Fqn,NodeSPI> lookedUpNodes)
Adds a map of looked up nodes to the current map of looked up nodes
|
void |
removeLock(Object lock)
Removes a lock from the currently maintained collection of locks acquired.
|
void |
reset()
Resets the context, freeing up any references.
|
void |
setBypassUnmarshalling(boolean b) |
void |
setCommand(VisitableCommand cacheCommand)
Deprecated.
|
void |
setFqnsLoaded(Set<Fqn> fqnsLoaded) |
void |
setGlobalTransaction(GlobalTransaction globalTransaction)
Sets the global transaction associated with this invocation
|
void |
setLocalRollbackOnly(boolean localRollbackOnly)
Marks teh context as only rolling back.
|
void |
setMethodCall(MethodCall methodCall)
Deprecated.
not used anymore. Interceptors will get a
ReplicableCommand instance passed in along with an InvocationContext. |
void |
setOptionOverrides(Option optionOverrides)
Sets the option overrides to be associated with this invocation
|
void |
setOriginLocal(boolean originLocal)
If set to true, the invocation is assumed to have originated locally.
|
void |
setState(InvocationContext template)
Sets the state of the InvocationContext based on the template context passed in
|
void |
setTransaction(Transaction transaction)
Sets a transaction object on the invocation context.
|
void |
setTransactionContext(TransactionContext transactionContext)
Sets the transaction context to be associated with the current thread.
|
void |
throwIfNeeded(Throwable e)
Throws the given throwable provided no options suppress or prevent this from happening.
|
String |
toString() |
protected TransactionContext transactionContext
protected LinkedHashSet invocationLocks
public abstract NodeSPI lookUpNode(Fqn fqn)
fqn
- fqn to look uppublic abstract void putLookedUpNode(Fqn f, NodeSPI n)
f
- fqn to addn
- node to addpublic abstract void putLookedUpNodes(Map<Fqn,NodeSPI> lookedUpNodes)
lookedUpNodes
- looked up nodes to addpublic abstract void clearLookedUpNodes()
public abstract Map<Fqn,NodeSPI> getLookedUpNodes()
public void setLocalRollbackOnly(boolean localRollbackOnly)
localRollbackOnly
- if true, the context is only rolling back.public Transaction getTransaction()
public void setTransaction(Transaction transaction)
transaction
- transaction to setpublic TransactionContext getTransactionContext()
public void setTransactionContext(TransactionContext transactionContext)
transactionContext
- transaction context to setpublic GlobalTransaction getGlobalTransaction()
public void setGlobalTransaction(GlobalTransaction globalTransaction)
globalTransaction
- global transaction to setpublic Option getOptionOverrides()
public boolean isOptionsUninitialised()
public void setOptionOverrides(Option optionOverrides)
optionOverrides
- options to setpublic boolean isOriginLocal()
public List getLocks()
TransactionContext
.
Retrieving locks from this method should always ensure they are retrieved from the appropriate scope.
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 Listpublic void addAllLocks(List locks)
TransactionContext
.
Adding locks using this method should always ensure they are applied to the appropriate scope.
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 Listlocks
- locks to addpublic void addLock(Object lock)
TransactionContext
.
Using this method should always ensure that the appropriate scope is used.
Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqn
s 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
.lock
- lock to addpublic void removeLock(Object lock)
TransactionContext
.
Using this method should always ensure that the lock is removed from the appropriate scope.
Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqn
s 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
.lock
- lock to removepublic void clearLocks()
TransactionContext
.
Using this method should always ensure locks are cleared in the appropriate scope.
Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses Fqn
s 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
.public boolean hasLock(Object lock)
TransactionContext
.
Using this method should always ensure locks checked in the appropriate scope.lock
- lock to testpublic boolean isLockingSuppressed()
PessimisticLockInterceptor
.public void setOriginLocal(boolean originLocal)
originLocal
- flag to setpublic boolean isLocalRollbackOnly()
public void reset()
public abstract InvocationContext copy()
TransactionContext
, if any, is maintained.public void setState(InvocationContext template)
template
- template to copy from@Deprecated public MethodCall getMethodCall()
@Deprecated public void setMethodCall(MethodCall methodCall)
ReplicableCommand
instance passed in along with an InvocationContext.methodCall
- methodcall to setpublic long getLockAcquisitionTimeout(long timeout)
timeout
- timeout to fall back to@Deprecated public void setCommand(VisitableCommand cacheCommand)
cacheCommand
- command to set@Deprecated public VisitableCommand getCommand()
setCommand(org.jboss.cache.commands.VisitableCommand)
public boolean isValidTransaction()
public void throwIfNeeded(Throwable e) throws Throwable
e
- throwable to throwThrowable
- if allowed to throw one.protected void doCopy(InvocationContext copy)
public void addFqnLoaded(Fqn fqn)
fqn
- fqn to addpublic Set<Fqn> getFqnsLoaded()
public void setBypassUnmarshalling(boolean b)
public boolean isBypassUnmarshalling()
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.