org.spicefactory.pimento.context
Class RequestContext

java.lang.Object
  extended by org.spicefactory.pimento.context.RequestContext

public class RequestContext
extends Object

The context for a single request. Primarily used internally by PhaseListener implementations that manage transactions and the persistence context. Also provides access to the active IoContext instance for classes that manage conversion from and to entity snapshots.

RequestContext instances will be associated with the thread of the request and can be retrieved with the static getCurrentInstance method.

Author:
Jens Halm

Constructor Summary
RequestContext()
           
 
Method Summary
static RequestContext getCurrentInstance()
          Returns the RequestContext for the current thread.
 IoContext getIoContext()
          Returns the IoContext for this request.
 Object getTransactionContext()
          Returns the transaction context for this request.
 boolean isNewEntityManager()
          Checks whether a new EntityManager was created by Pimento for this request.
 void setIoContext(IoContext ioContext)
          Sets the IoContext for this request.
 void setNewEntityManager(boolean newEntityManager)
          Specifies whether a new EntityManager was created by Pimento for this request.
 void setTransactionContext(Object tx)
          Sets the transaction context for this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestContext

public RequestContext()
Method Detail

getCurrentInstance

public static RequestContext getCurrentInstance()
Returns the RequestContext for the current thread.

Returns:
the RequestContext for the current thread

getTransactionContext

public Object getTransactionContext()
Returns the transaction context for this request. The type of object depends on the transaction management framework in use.

Returns:
the transaction context for this request

setTransactionContext

public void setTransactionContext(Object tx)
Sets the transaction context for this request.

Parameters:
tx - the transaction context for this request

isNewEntityManager

public boolean isNewEntityManager()
Checks whether a new EntityManager was created by Pimento for this request.

Returns:
true if a new EntityManager was created by Pimento for this request

setNewEntityManager

public void setNewEntityManager(boolean newEntityManager)
Specifies whether a new EntityManager was created by Pimento for this request.

Parameters:
newEntityManager - true if a new EntityManager was created by Pimento for this request

getIoContext

public IoContext getIoContext()
Returns the IoContext for this request.

Returns:
the IoContext for this request

setIoContext

public void setIoContext(IoContext ioContext)
Sets the IoContext for this request.

Parameters:
ioContext - the IoContext for this request