FileDocCategorySizeDatePackage
StatelessInstanceInterceptor.javaAPI DocJBoss 4.2.12721Fri Jul 13 20:53:52 BST 2007org.jboss.ejb3.stateless

StatelessInstanceInterceptor

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

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


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

      EJBContainerInvocation ejb = (EJBContainerInvocation) invocation;
      EJBContainer container = (EJBContainer)ejb.getAdvisor();
      Pool pool = container.getPool();
      BeanContext ctx = pool.get();
      ejb.setTargetObject(ctx.getInstance());
      ejb.setBeanContext(ctx);

      boolean discard = false;

      try
      {
         return ejb.invokeNext();
      }
      catch (Exception ex)
      {
         discard = (ex instanceof EJBException) ||
                 ((ex instanceof RuntimeException || ex instanceof RemoteException) && !StatefulInstanceInterceptor.isApplicationException(ex.getClass(), container));
         throw ex;
      }
      finally
      {                                                                                   
         ejb.setTargetObject(null);
         ejb.setBeanContext(null);
         if (discard) pool.discard(ctx);
         else pool.release(ctx);
      }