org.apache.myfaces.extensions.cdi.jpa.impl.transaction.context
Class TransactionBeanStorage

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.jpa.impl.transaction.context.TransactionBeanStorage

@RequestScoped
public class TransactionBeanStorage
extends Object

This bean stores information about @TransactionScoped contextual instances, their CreationalContext etc.

We use a RequestScoped bean because this way we don't need to take care about cleaning up any ThreadLocals ourselves. This also makes sure that we subsequently destroy any left over TransactionScoped beans (which should not happen, but who knows). We also don't need to do any fancy synchronization stuff since we are sure that we are always in the same Thread.


Constructor Summary
TransactionBeanStorage()
           
 
Method Summary
 String activateTransactionScope(String transactionKey)
          Activate the TransactionScope with the given qualifier.
 void endAllTransactionScopes()
          This will destroy all stored transaction contexts.
 void endTransactionScope(String transactionKey)
          End the TransactionScope with the given qualifier.
 Map<javax.enterprise.context.spi.Contextual,TransactionBeanEntry> getActiveTransactionContext()
           
 void requestEnded()
          At the end of the request we will destroy all beans still stored in the context.
 void startTransactionScope(String transactionKey)
          Start the TransactionScope with the given qualifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionBeanStorage

public TransactionBeanStorage()
Method Detail

startTransactionScope

public void startTransactionScope(String transactionKey)
Start the TransactionScope with the given qualifier

Parameters:
transactionKey -

endTransactionScope

public void endTransactionScope(String transactionKey)
End the TransactionScope with the given qualifier. This will subsequently destroy all beans which are stored in the context

Parameters:
transactionKey -

activateTransactionScope

public String activateTransactionScope(String transactionKey)
Activate the TransactionScope with the given qualifier. This is needed if a subsequently invoked @Transactional method will switch to another persistence unit. This method must also be invoked when the transaction just got started with startTransactionScope(String).

Parameters:
transactionKey -
Returns:
the transactionKey of the previously activated transaction or null if non exists

endAllTransactionScopes

public void endAllTransactionScopes()
This will destroy all stored transaction contexts.


getActiveTransactionContext

public Map<javax.enterprise.context.spi.Contextual,TransactionBeanEntry> getActiveTransactionContext()
Returns:
the Map which represents the currently active Context content.

requestEnded

@PreDestroy
public void requestEnded()
At the end of the request we will destroy all beans still stored in the context.



Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.