org.jboss.cache
Class InvocationContext

java.lang.Object
  extended by org.jboss.cache.InvocationContext
All Implemented Interfaces:
Cloneable

public class InvocationContext
extends Object
implements Cloneable

This context holds information specific to a method invocation.

Author:
Manik Surtani (manik@jboss.org)

Constructor Summary
InvocationContext()
           
 
Method Summary
 void addInvocationLockAcquired(NodeLock l)
           
 void addInvocationLocksAcquired(Collection<NodeLock> locks)
           
 void clearInvocationLocksAcquired()
          for non-tx calls, release any locks acquired.
 InvocationContext clone()
           
 boolean equals(Object o)
           
static InvocationContext fromMethodCall(MethodCall methodCall)
          Factory method that creates a context with a given method call.
 VisitableCommand getCommand()
          Deprecated. 
 long getContextLockAcquisitionTimeout(long timeout)
          If the acq timeout if overwritten for current call, then return that one.
 GlobalTransaction getGlobalTransaction()
          Retrieves the global transaction associated with this invocation
 List<NodeLock> getInvocationLocksAcquired()
           
 MethodCall getMethodCall()
          Deprecated. 
 Option getOptionOverrides()
          Retrieves the option overrides associated with this invocation
 Transaction getTransaction()
          Retrieves the transaction associated with this invocation
 int hashCode()
           
 boolean isCacheLoaderHasMods()
          Cache loader might have mods which are different from TX's mods; e.g.
 boolean isLocalRollbackOnly()
           
 boolean isLockingSuppressed()
           
 boolean isOptionsUninitialised()
           
 boolean isOriginLocal()
          Tests if this invocation originated locally or from a remote cache.
 boolean isTxHasMods()
           
 boolean isValidTransaction()
           
 void reset()
          Resets this to the defaults used when constructing an invocation context object
 void setCacheLoaderHasMods(boolean cacheLoaderHasMods)
           
 void setCommand(VisitableCommand cacheCommand)
          Deprecated. 
 void setGlobalTransaction(GlobalTransaction globalTransaction)
          Sets the global transaction associated with this invocation
 void setLocalRollbackOnly(boolean localRollbackOnly)
          Wipe list of previously peeked nodes.
 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 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 the transaction associated with this invocation
 void setTxHasMods(boolean b)
           
 void throwIfNeeded(Throwable e)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvocationContext

public InvocationContext()
Method Detail

setLocalRollbackOnly

public void setLocalRollbackOnly(boolean localRollbackOnly)
Wipe list of previously peeked nodes.

Since:
2.1.0

getTransaction

public Transaction getTransaction()
Retrieves the transaction associated with this invocation

Returns:
The transaction associated with this invocation

setTransaction

public void setTransaction(Transaction transaction)
Sets the transaction associated with this invocation

Parameters:
transaction -

getGlobalTransaction

public GlobalTransaction getGlobalTransaction()
Retrieves the global transaction associated with this invocation

Returns:
the global transaction associated with this invocation

setGlobalTransaction

public void setGlobalTransaction(GlobalTransaction globalTransaction)
Sets the global transaction associated with this invocation

Parameters:
globalTransaction -

getOptionOverrides

public Option getOptionOverrides()
Retrieves the option overrides associated with this invocation

Returns:
the option overrides associated with this invocation

isOptionsUninitialised

public boolean isOptionsUninitialised()

setOptionOverrides

public void setOptionOverrides(Option optionOverrides)
Sets the option overrides associated with this invocation

Parameters:
optionOverrides -

isOriginLocal

public boolean isOriginLocal()
Tests if this invocation originated locally or from a remote cache.

Returns:
true if the invocation originated locally.

getInvocationLocksAcquired

public List<NodeLock> getInvocationLocksAcquired()

addInvocationLocksAcquired

public void addInvocationLocksAcquired(Collection<NodeLock> locks)

addInvocationLockAcquired

public void addInvocationLockAcquired(NodeLock l)

clearInvocationLocksAcquired

public void clearInvocationLocksAcquired()
for non-tx calls, release any locks acquired. These used to be in a separate Map> called a lockTable, but that has been dropped in facour of storing the invocation-specific locks in the invocation context. Cleaner to have it all in one place, plus much more performant.


isLockingSuppressed

public boolean isLockingSuppressed()
Returns:
true if options exist to suppress locking - false otherwise. Note that this is only used by the PessimisticLockInterceptor.

setOriginLocal

public void setOriginLocal(boolean originLocal)
If set to true, the invocation is assumed to have originated locally. If set to false, assumed to have originated from a remote cache.

Parameters:
originLocal -

toString

public String toString()
Overrides:
toString in class Object

isTxHasMods

public boolean isTxHasMods()

setTxHasMods

public void setTxHasMods(boolean b)

isCacheLoaderHasMods

public boolean isCacheLoaderHasMods()
Cache loader might have mods which are different from TX's mods; e.g. when cache is local and passivation is on.


setCacheLoaderHasMods

public void setCacheLoaderHasMods(boolean cacheLoaderHasMods)

isLocalRollbackOnly

public boolean isLocalRollbackOnly()

reset

public void reset()
Resets this to the defaults used when constructing an invocation context object


clone

public InvocationContext clone()
                        throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

setState

public void setState(InvocationContext template)
Sets the state of the InvocationContext based on the template context passed in

Parameters:
template -

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getMethodCall

@Deprecated
public MethodCall getMethodCall()
Deprecated. 

Returns:
the method call associated with this invocation

setMethodCall

@Deprecated
public void setMethodCall(MethodCall methodCall)
Deprecated. not used anymore. Interceptors will get a ReplicableCommand instance passed in along with an InvocationContext.

Sets the method call associated with this invocation.

Parameters:
methodCall - methodcall to set

fromMethodCall

public static InvocationContext fromMethodCall(MethodCall methodCall)
Factory method that creates a context with a given method call.

Parameters:
methodCall - methodcall to use
Returns:
invocation context

getContextLockAcquisitionTimeout

public long getContextLockAcquisitionTimeout(long timeout)
If the acq timeout if overwritten for current call, then return that one. If not overwritten return default value.


setCommand

@Deprecated
public void setCommand(VisitableCommand cacheCommand)
Deprecated. 

This is only used for backward compatibility with old interceptors implementation and should NOT be use by any new custom interceptors. The commands is now passed in as the second param in each implementing handlers (handler = method in ChainedInterceptor class)


getCommand

@Deprecated
public VisitableCommand getCommand()
Deprecated. 

See Also:
setCommand(org.jboss.cache.commands.VisitableCommand)

isValidTransaction

public boolean isValidTransaction()

throwIfNeeded

public void throwIfNeeded(Throwable e)
                   throws Throwable
Throws:
Throwable


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