org.infinispan.context
Interface InvocationContextContainer

All Known Implementing Classes:
InvocationContextContainerImpl

public interface InvocationContextContainer

Manages the association between an InvocationContext and the calling thread. Also acts as a factory for creating various types of InvocationContexts.

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

Method Summary
 InvocationContext createInvocationContext()
          If we are in a tx scope this will return an TxInvocationContext.
 NonTxInvocationContext createNonTxInvocationContext()
          Will create an NonTxInvocationContext with the NonTxInvocationContext.isOriginLocal() returning true.
 InvocationContext createRemoteInvocationContext()
          Returns an NonTxInvocationContext whose NonTxInvocationContext.isOriginLocal() flag will be true.
 InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand)
          As createRemoteInvocationContext(), but returning the flags to the context from the Command if any Flag was set.
 RemoteTxInvocationContext createRemoteTxInvocationContext()
          Returns an RemoteTxInvocationContext.
 LocalTxInvocationContext createTxInvocationContext()
          Returns a LocalTxInvocationContext.
 InvocationContext getInvocationContext()
          Returns the InvocationContext that is currently associated with the calling thread.
 void resume(InvocationContext ic)
          Associates the supplied InvocationContext with the calling thread.
 InvocationContext suspend()
          Disassociates thread's invocation context and returns the existing value.
 

Method Detail

createInvocationContext

InvocationContext createInvocationContext()
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 getInvocationContext() will return same instance.


createNonTxInvocationContext

NonTxInvocationContext createNonTxInvocationContext()
Will create an NonTxInvocationContext with the NonTxInvocationContext.isOriginLocal() returning true.


createTxInvocationContext

LocalTxInvocationContext createTxInvocationContext()
Returns a LocalTxInvocationContext. The context is also associated with the current thread, so further calls to getInvocationContext() will return same instance.


createRemoteTxInvocationContext

RemoteTxInvocationContext createRemoteTxInvocationContext()
Returns an RemoteTxInvocationContext. The context is also associated with the current thread, so further calls to getInvocationContext() will return same instance.


createRemoteInvocationContext

InvocationContext createRemoteInvocationContext()
Returns an NonTxInvocationContext whose NonTxInvocationContext.isOriginLocal() flag will be true. The context is also associated with the current thread, so further calls to getInvocationContext() will return same instance.


createRemoteInvocationContextForCommand

InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand)
As createRemoteInvocationContext(), but returning the flags to the context from the Command if any Flag was set.

Parameters:
cacheCommand -

getInvocationContext

InvocationContext getInvocationContext()
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.

Throws:
IllegalStateException - if there is no context associated with the current thread.

suspend

InvocationContext suspend()
Disassociates thread's invocation context and returns the existing value.


resume

void resume(InvocationContext ic)
Associates the supplied InvocationContext with the calling thread.



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