3 Replies Latest reply on May 11, 2009 2:25 PM by jaikiran

    Unexpected behaviour in PER_CLASS_JOINPOINT aspect factories

    jaikiran

      Currently in EJB3, we have this declaration for an AspectFactory:

      <interceptor factory="org.jboss.ejb3.tx.CMTTxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
      
      ...
      
      <domain name="Stateless Bean" extends="Intercepted Bean" inheritBindings="true">
      ...
       <bind pointcut="execution(public * *->*(..))">
       ...
       <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
      
      


      Complete file is here http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml

      Based on this declaration, i would have expected that the CMTTxInterceptorFactory would be created one per class join point. However, currently (in AS 5_x branch) we are seeing that this factory (and other factories marked for PER_CLASS_JOINPOINT) is being created for every method join point on which the expression is applied. Here's the appropriate call trace which instantiates this factory for each method join point:

       at org.jboss.ejb3.tx.CMTTxInterceptorFactory.<init>(CMTTxInterceptorFactory.java:53)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
       at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:149)
       at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:106)
       at org.jboss.joinpoint.plugins.BasicConstructorJoinPoint.dispatch(BasicConstructorJoinPoint.java:80)
       at org.jboss.beans.metadata.plugins.factory.GenericBeanFactory.createBean(GenericBeanFactory.java:212)
       at org.jboss.beans.metadata.plugins.factory.GenericBeanFactory.createBean(GenericBeanFactory.java:81)
       at org.jboss.aop.microcontainer.beans.ClassLoaderAwareGenericBeanFactory.createBean(ClassLoaderAwareGenericBeanFactory.java:66)
       at org.jboss.aop.microcontainer.beans.DelegatingBeanAspectFactory.doCreate(DelegatingBeanAspectFactory.java:132)
       at org.jboss.aop.microcontainer.beans.DelegatingBeanAspectFactory.createPerJoinpoint(DelegatingBeanAspectFactory.java:105)
       at org.jboss.aop.advice.ScopedInterceptorFactory.create(ScopedInterceptorFactory.java:116)
       at org.jboss.aop.Advisor.createInterceptorChain(Advisor.java:1318)
       at org.jboss.ejb3.interceptors.container.ManagedObjectAdvisor.createInterceptorChain(ManagedObjectAdvisor.java:141)
       at org.jboss.aop.Advisor.pointcutResolved(Advisor.java:1932)
       at org.jboss.aop.MethodMatchInfo.applyBinding(MethodMatchInfo.java:152)
       at org.jboss.aop.MethodMatchInfo.overridePopulateBindings(MethodMatchInfo.java:143)
       at org.jboss.aop.MethodMatchInfo.populateBindings(MethodMatchInfo.java:92)
       at org.jboss.aop.Advisor.finalizeMethodChain(Advisor.java:1543)
       at org.jboss.aop.ClassAdvisor.finalizeChains(ClassAdvisor.java:739)
       at org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:607)
      


      Any reason why this is happening? And any workarounds?