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

ExtendedPersistenceContextPropagationInterceptor

public class ExtendedPersistenceContextPropagationInterceptor extends Object implements org.jboss.aop.advice.Interceptor
author
Bill Burke
version
$Revision: 57207 $

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)

      log.debug("++++ LongLivedSessionPropagationInterceptor");
      StatefulContainerInvocation ejb = (StatefulContainerInvocation) invocation;
      StatefulBeanContext ctx = (StatefulBeanContext) ejb.getBeanContext();

      Map<String, EntityManager> extendedPCs = ctx.getExtendedPersistenceContexts();
      if (extendedPCs == null || extendedPCs.size() == 0)
      {
         return invocation.invokeNext();
      }

      TransactionManager tm = TxUtil.getTransactionManager();
      if (tm.getTransaction() != null)
      {
         for (String kernelname : extendedPCs.keySet())
         {
            EntityManager manager = extendedPCs.get(kernelname);
            ManagedEntityManagerFactory factory = PersistenceUnitRegistry.getPersistenceUnit(kernelname).getManagedFactory();
            factory.registerExtendedWithTransaction(manager);
         }
      }

      return invocation.invokeNext();