0 Replies Latest reply on Apr 3, 2008 8:56 AM by Kabir Khan

    Change GeneratedAOPProxyFactory check for whether should cre

    Kabir Khan Master

      From http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141090#4141090

      "kabir.khan@jboss.com" wrote:
      I could add something to AOP to determine if the instance annotation actually ends up resulting in more aspects (not lifecycle callbacks), and if that is the case return a proxy?


      At the moment the GeneratedAOPProxyFactory will create a proxy if there are some introductions or if there are interface introductions, mixins, simplemetadata or instance level metadata
       if (!params.getContainerCache().hasAspects() && !params.getContainerCache().requiresInstanceAdvisor())
       {
       return params.getTarget();
       }
       else
       {
       proxyClass = generateProxy(params);
       }
      


      IIRC the reason for this condition was that having an introductions, metadata etc would mean that we could match more pointcuts. However,
      at the time this check is done, an instance advisor will have been generated if the condition was met, so I think the check should be changed to only return a proxy if the instance advisor has more aspects than the class advisor? Something like the following (pseudo-code):
      ContainerCache cache = params.getContainerCache();
      
       if (!cache.hasAspects() || (cache.hasAspects() && cache.hasMoreAspectsForInstanceThanInClassContainer()))
       {
       return params.getTarget();
       }
       else
       {
       proxyClass = generateProxy(params);
       }
      


      This would mean modifying the aop-mc-int tests under org.jboss.test.microcontainer.matrix.mc.test (and possibly some others)