org.infinispan.context
Class InvocationContextContainerImpl

java.lang.Object
  extended by org.infinispan.context.InvocationContextContainerImpl
All Implemented Interfaces:
InvocationContextContainer

public class InvocationContextContainerImpl
extends Object
implements InvocationContextContainer

Default implementation for InvocationContextContainer.

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Mircea.Markus@jboss.com

Constructor Summary
InvocationContextContainerImpl()
           
 
Method Summary
 InvocationContext createInvocationContext()
          If we are in a tx scope this will return an TxInvocationContext.
 InvocationContext createInvocationContext(Transaction tx)
          Creates an invocation context
 NonTxInvocationContext createNonTxInvocationContext()
          Will create an NonTxInvocationContext with the NonTxInvocationContext.isOriginLocal() returning true.
 NonTxInvocationContext createRemoteInvocationContext(Address origin)
          Returns an NonTxInvocationContext whose NonTxInvocationContext.isOriginLocal() flag will be true.
 InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand, Address origin)
          As #createRemoteInvocationContext(), but returning the flags to the context from the Command if any Flag was set.
 RemoteTxInvocationContext createRemoteTxInvocationContext(Address origin)
          Returns an RemoteTxInvocationContext.
 LocalTxInvocationContext createTxInvocationContext()
          Returns a LocalTxInvocationContext.
 InvocationContext getInvocationContext()
          Returns the InvocationContext that is currently associated with the calling thread.
 void init(TransactionManager tm, TransactionTable transactionTable)
           
 void resume(InvocationContext ctxt)
          Associates the supplied InvocationContext with the calling thread.
 InvocationContext suspend()
          Disassociates thread's invocation context and returns the existing value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvocationContextContainerImpl

public InvocationContextContainerImpl()
Method Detail

init

public void init(TransactionManager tm,
                 TransactionTable transactionTable)

createInvocationContext

public InvocationContext createInvocationContext()
Description copied from interface: InvocationContextContainer
If we are in a tx scope this will return an TxInvocationContext. Otherwise it will return an NonTxInvocationContext. Either way, both context will be marked as local, i.e. InvocationContext.isOriginLocal() will be true. The context is also associated with the current thread, so further calls to InvocationContextContainer.getInvocationContext() will return same instance.

Specified by:
createInvocationContext in interface InvocationContextContainer

createInvocationContext

public InvocationContext createInvocationContext(Transaction tx)
Description copied from interface: InvocationContextContainer
Creates an invocation context

Specified by:
createInvocationContext in interface InvocationContextContainer
Returns:

createTxInvocationContext

public LocalTxInvocationContext createTxInvocationContext()
Description copied from interface: InvocationContextContainer
Returns a LocalTxInvocationContext. The context is also associated with the current thread, so further calls to InvocationContextContainer.getInvocationContext() will return same instance.

Specified by:
createTxInvocationContext in interface InvocationContextContainer

createRemoteTxInvocationContext

public RemoteTxInvocationContext createRemoteTxInvocationContext(Address origin)
Description copied from interface: InvocationContextContainer
Returns an RemoteTxInvocationContext. The context is also associated with the current thread, so further calls to InvocationContextContainer.getInvocationContext() will return same instance.

Specified by:
createRemoteTxInvocationContext in interface InvocationContextContainer
Parameters:
origin - the origin of the command, or null if local

createNonTxInvocationContext

public NonTxInvocationContext createNonTxInvocationContext()
Description copied from interface: InvocationContextContainer
Will create an NonTxInvocationContext with the NonTxInvocationContext.isOriginLocal() returning true.

Specified by:
createNonTxInvocationContext in interface InvocationContextContainer

createRemoteInvocationContextForCommand

public InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand,
                                                                 Address origin)
Description copied from interface: InvocationContextContainer
As #createRemoteInvocationContext(), but returning the flags to the context from the Command if any Flag was set.

Specified by:
createRemoteInvocationContextForCommand in interface InvocationContextContainer
origin - the origin of the command, or null if local

createRemoteInvocationContext

public NonTxInvocationContext createRemoteInvocationContext(Address origin)
Description copied from interface: InvocationContextContainer
Returns an NonTxInvocationContext whose NonTxInvocationContext.isOriginLocal() flag will be true. The context is also associated with the current thread, so further calls to InvocationContextContainer.getInvocationContext() will return same instance.

Specified by:
createRemoteInvocationContext in interface InvocationContextContainer
Parameters:
origin - the origin of the command, or null if local

getInvocationContext

public InvocationContext getInvocationContext()
Description copied from interface: InvocationContextContainer
Returns the InvocationContext that is currently associated with the calling thread. Important: implementations of this method is most likely expensive (ThreadLocal.get), it is recommended to cache the result of this method rather than repeating the call.

Specified by:
getInvocationContext in interface InvocationContextContainer

suspend

public InvocationContext suspend()
Description copied from interface: InvocationContextContainer
Disassociates thread's invocation context and returns the existing value.

Specified by:
suspend in interface InvocationContextContainer

resume

public void resume(InvocationContext ctxt)
Description copied from interface: InvocationContextContainer
Associates the supplied InvocationContext with the calling thread.

Specified by:
resume in interface InvocationContextContainer

-->

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