FileDocCategorySizeDatePackage
SessionSynchronizationInterceptor.javaAPI DocJBoss 4.2.14295Fri Jul 13 20:53:50 BST 2007org.jboss.ejb3.stateful

SessionSynchronizationInterceptor

public class SessionSynchronizationInterceptor extends Object implements org.jboss.aop.advice.Interceptor
Comment
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
private TransactionManager
tm
Constructors Summary
public SessionSynchronizationInterceptor()

      this.tm = TxUtil.getTransactionManager();
   
Methods Summary
public java.lang.StringgetName()

      return null;
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      StatefulContainerInvocation ejb = (StatefulContainerInvocation) invocation;
      StatefulBeanContext target = (StatefulBeanContext) ejb.getBeanContext();
      if (target.getInstance() instanceof SessionSynchronization)
      {
         registerSessionSynchronization(target);
      }
      return ejb.invokeNext();
   
protected voidregisterSessionSynchronization(StatefulBeanContext ctx)

      if (ctx.isTxSynchronized()) return;
      Transaction tx = tm.getTransaction();
      if (tx == null) return;
      if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) return;
      SFSBSessionSynchronization synch = new SFSBSessionSynchronization(ctx);
      SessionSynchronization bean = (SessionSynchronization) ctx.getInstance();
      try
      {
         bean.afterBegin();
      }
      catch (EJBException e)
      {
         throw e;
      }
      catch (RemoteException e)
      {
         throw new EJBException(e);
      }
      try
      {
         tx.registerSynchronization(synch);
      }
      catch (RollbackException ignore)
      {
      }