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

@Typed
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.


Method Summary
static TransactionBeanStorage activateNewStorage()
          Creates a new storage for the current thread
 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()
           
 String getActiveTransactionKey()
           
static TransactionBeanStorage getStorage()
           
static void resetStorage()
          Removes the current storage
 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
 

Method Detail

getStorage

public static TransactionBeanStorage getStorage()
Returns:
the storage for the current thread if there is one - null otherwise

activateNewStorage

public static TransactionBeanStorage activateNewStorage()
Creates a new storage for the current thread

Returns:
the storage which was associated with the thread before - null if there was no storage

resetStorage

public static void resetStorage()
Removes the current storage


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

getActiveTransactionKey

public String getActiveTransactionKey()

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.


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