org.infinispan.context
Class InvocationContextImpl

java.lang.Object
  extended by org.infinispan.context.AbstractContext
      extended by org.infinispan.context.InvocationContextImpl
All Implemented Interfaces:
EntryLookup, FlagContainer, InvocationContext

public class InvocationContextImpl
extends AbstractContext
implements InvocationContext


Nested Class Summary
 
Nested classes/interfaces inherited from class org.infinispan.context.AbstractContext
AbstractContext.ContextFlags
 
Field Summary
protected  TransactionContext transactionContext
           
 
Fields inherited from class org.infinispan.context.AbstractContext
contextFlags, flags, lookedUpEntries
 
Constructor Summary
InvocationContextImpl()
           
 
Method Summary
 void clearLookedUpEntries()
          Clears the collection of entries looked up
 InvocationContext copy()
           
 boolean equals(Object o)
           
 GlobalTransaction getGlobalTransaction()
          Retrieves the global transaction associated with this invocation
protected  int getLockSetSize()
           
 BidirectionalMap<Object,CacheEntry> getLookedUpEntries()
          Retrieves a map of entries looked up within the current scope.
 Transaction getTransaction()
          Retrieves the transaction associated with this invocation
 TransactionContext getTransactionContext()
           
 int hashCode()
           
 boolean hasLockedKey(Object key)
          Note that if a transaction is in scope, implementations should test this lock from on TransactionContext.
 boolean isContainsLocks()
           
 boolean isContainsModifications()
           
 boolean isLocalRollbackOnly()
           
 boolean isOriginLocal()
          Tests if this invocation originated locally or from a remote cache.
 boolean isValidTransaction()
           
 CacheEntry lookupEntry(Object k)
          Retrieves an entry from the collection of looked up entries in the current scope.
 void putLookedUpEntries(Map<Object,CacheEntry> lookedUpEntries)
           
 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 reset()
          Resets the context, freeing up any references.
 void setContainsLocks(boolean b)
          Sets whether locks have been acquired in the current context
 void setContainsModifications(boolean b)
          Sets whether modifications have been made in the current context
 void setGlobalTransaction(GlobalTransaction globalTransaction)
          Sets the global transaction associated with this invocation
 void setLocalRollbackOnly(boolean localRollbackOnly)
          Marks teh context as only rolling back.
 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.
 String toString()
           
 
Methods inherited from class org.infinispan.context.AbstractContext
copyInto, getFlags, hasFlag, isContextFlagSet, isFlagsUninitialized, resetFlags, setContextFlag, setContextFlag, setFlags, setFlags, unsetContextFlag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.infinispan.context.FlagContainer
getFlags, hasFlag, isFlagsUninitialized, resetFlags, setFlags, setFlags
 

Field Detail

transactionContext

protected volatile TransactionContext transactionContext
Constructor Detail

InvocationContextImpl

public InvocationContextImpl()
Method Detail

getLockSetSize

protected final int getLockSetSize()
Specified by:
getLockSetSize in class AbstractContext

hasLockedKey

public boolean hasLockedKey(Object key)
Description copied from interface: EntryLookup
Note that if a transaction is in scope, implementations should test this lock from on TransactionContext. Using this method should always ensure locks checked in the appropriate scope.

Specified by:
hasLockedKey in interface EntryLookup
Overrides:
hasLockedKey in class AbstractContext
Parameters:
key - lock to test
Returns:
true if the lock being tested is already held in the current scope, false otherwise.

lookupEntry

public CacheEntry lookupEntry(Object k)
Description copied from interface: EntryLookup
Retrieves an entry from the collection of looked up entries in the current scope.

If a transaction is in progress, implementations should delegate to the same method in TransactionContext.

Specified by:
lookupEntry in interface EntryLookup
Overrides:
lookupEntry in class AbstractContext
Parameters:
k - key to look up
Returns:
an entry, or null if it cannot be found.

removeLookedUpEntry

public void removeLookedUpEntry(Object key)
Specified by:
removeLookedUpEntry in interface EntryLookup
Overrides:
removeLookedUpEntry in class AbstractContext

putLookedUpEntry

public 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.

If a transaction is in progress, implementations should delegate to the same method in TransactionContext.

Specified by:
putLookedUpEntry in interface EntryLookup
Overrides:
putLookedUpEntry in class AbstractContext
Parameters:
key - key to store
e - entry to store

putLookedUpEntries

public void putLookedUpEntries(Map<Object,CacheEntry> lookedUpEntries)
Specified by:
putLookedUpEntries in interface EntryLookup
Overrides:
putLookedUpEntries in class AbstractContext

clearLookedUpEntries

public void clearLookedUpEntries()
Description copied from interface: EntryLookup
Clears the collection of entries looked up

Specified by:
clearLookedUpEntries in interface EntryLookup
Overrides:
clearLookedUpEntries in class AbstractContext

getLookedUpEntries

public BidirectionalMap<Object,CacheEntry> getLookedUpEntries()
Description copied from interface: EntryLookup
Retrieves a map of entries looked up within the current scope.

If a transaction is in progress, implementations should delegate to the same method in TransactionContext.

Specified by:
getLookedUpEntries in interface EntryLookup
Overrides:
getLookedUpEntries in class AbstractContext
Returns:
a map of looked up entries.

copy

public InvocationContext copy()
Specified by:
copy in interface InvocationContext

setLocalRollbackOnly

public void setLocalRollbackOnly(boolean localRollbackOnly)
Marks teh context as only rolling back.

Specified by:
setLocalRollbackOnly in interface InvocationContext
Parameters:
localRollbackOnly - if true, the context is only rolling back.

getTransaction

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

Specified by:
getTransaction in interface InvocationContext
Returns:
The transaction associated with this invocation

setTransaction

public void setTransaction(Transaction transaction)
Sets a transaction object on the invocation context.

Specified by:
setTransaction in interface InvocationContext
Parameters:
transaction - transaction to set

getTransactionContext

public TransactionContext getTransactionContext()
Specified by:
getTransactionContext in interface InvocationContext
Returns:
the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
Since:
4.0

setTransactionContext

public void setTransactionContext(TransactionContext transactionContext)
Sets the transaction context to be associated with the current thread.

Specified by:
setTransactionContext in interface InvocationContext
Parameters:
transactionContext - transaction context to set
Since:
4.0

getGlobalTransaction

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

Specified by:
getGlobalTransaction in interface InvocationContext
Returns:
the global transaction associated with this invocation

setGlobalTransaction

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

Specified by:
setGlobalTransaction in interface InvocationContext
Parameters:
globalTransaction - global transaction to set

isOriginLocal

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

Specified by:
isOriginLocal in interface InvocationContext
Returns:
true if the invocation originated locally.

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.

Specified by:
setOriginLocal in interface InvocationContext
Parameters:
originLocal - flag to set

isLocalRollbackOnly

public boolean isLocalRollbackOnly()
Specified by:
isLocalRollbackOnly in interface InvocationContext
Returns:
true if the current transaction is set to rollback only.

reset

public void reset()
Resets the context, freeing up any references.

Specified by:
reset in interface InvocationContext
Overrides:
reset in class AbstractContext

setState

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

Specified by:
setState in interface InvocationContext
Parameters:
template - template to copy from

isValidTransaction

public boolean isValidTransaction()
Specified by:
isValidTransaction in interface InvocationContext
Returns:
true if there is current transaction associated with the invocation, and this transaction is in a valid state.

isContainsModifications

public boolean isContainsModifications()
Specified by:
isContainsModifications in interface EntryLookup
Overrides:
isContainsModifications in class AbstractContext
Returns:
true if the context contains modifications, false otherwise

setContainsModifications

public void setContainsModifications(boolean b)
Description copied from interface: EntryLookup
Sets whether modifications have been made in the current context

Specified by:
setContainsModifications in interface EntryLookup
Overrides:
setContainsModifications in class AbstractContext

isContainsLocks

public boolean isContainsLocks()
Specified by:
isContainsLocks in interface EntryLookup
Overrides:
isContainsLocks in class AbstractContext
Returns:
true if the context contains locks, false otherwise

setContainsLocks

public void setContainsLocks(boolean b)
Description copied from interface: EntryLookup
Sets whether locks have been acquired in the current context

Specified by:
setContainsLocks in interface EntryLookup
Overrides:
setContainsLocks in class AbstractContext

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractContext

toString

public String toString()
Overrides:
toString in class Object


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