FileDocCategorySizeDatePackage
TransactionScopedEntityManagerInterceptor.javaAPI DocJBoss 4.2.12496Fri Jul 13 20:53:58 BST 2007org.jboss.ejb3.entity

TransactionScopedEntityManagerInterceptor

public class TransactionScopedEntityManagerInterceptor extends Object implements org.jboss.aop.advice.Interceptor
If a transaction-scoped entitymanager is accessed outside of a transaction an entitymanager is created for the duration of the current EJB method call this entitymanager must be closed at the end of the method invocation.
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
private static final Logger
log
Constructors Summary
Methods Summary
public java.lang.StringgetName()


     
   
      return this.getClass().getName();
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      try
      {
         ManagedEntityManagerFactory.nonTxStack.push(new IdentityHashMap());
         return invocation.invokeNext();
      }
      finally
      {
         Map map = ManagedEntityManagerFactory.nonTxStack.pop();
         for (Object obj : map.values())
         {
            try
            {
               ((EntityManager)obj).close();
               log.debug("********************* CLOSING tx scoped nontx entity manager");
            }
            catch (Exception ignored)
            {
            }
         }
      }