4 Replies Latest reply on Apr 28, 2009 10:11 AM by Scott Stark

    Intercepting ManagedComponent ctor

    Scott Stark Master

      I'm not able to get the ManagedComponentImpl ctor intercepted if I add the following bootstrap xml to the aop.xml/AspectManager ctor:

       <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5">
       <constructor>
       <parameter><![CDATA[
       <aop>
       <aspect xmlns="urn:jboss:aop-beans:1.0"
       class="org.jboss.profileservice.aop.ManagedComponentAdvice" />
      
       <bind pointcut="execution(org.jboss.managed.plugins.ManagedComponentImpl->new(..))">
       <advice aspect="org.jboss.profileservice.aop.ManagedComponentAdvice" name="constructorAdvice"/>
       </bind>
       </aop>]]>
       </parameter>
       </constructor>
      


      I assume this because this class is being loaded too early by something. Is there a way to get the bootstrap classes intercepted?


        • 1. Re: Intercepting ManagedComponent ctor
          Ales Justin Master

          You could pre-aspectize them?

          btw: I don't this you should mix the profileservice code/config with aop's
          --> aspect and binding should be in profile.xml

          • 2. Re: Intercepting ManagedComponent ctor
            Scott Stark Master

             

            "alesj" wrote:
            You could pre-aspectize them?

            btw: I don't this you should mix the profileservice code/config with aop's
            --> aspect and binding should be in profile.xml

            I would if this was working. I was trying to load the aspects as soon as possible to see if it could be applied without having to compile the aspects in.


            • 3. Re: Intercepting ManagedComponent ctor
              Kabir Khan Master

              When/how is ManagedComponentImpl instantiated and intercepted?

              IIRC you used to do this with AOP proxies? If that is the case you need to invoke the constructor aspects yourself as is done for MC beans in AOPConstructorJoinPoint

               private Object createTarget(ContainerCache cache, AOPProxyFactoryParameters params) throws Throwable
               {
               Advisor advisor = cache.getAdvisor();
               if (advisor != null)
               {
               org.jboss.aop.ConstructorInfo aopinfo = findAopConstructorInfo(advisor);
              
               Interceptor[] interceptors = (aopinfo != null) ? aopinfo.getInterceptors() : null;
              
               if (interceptors != null)
               {
               ConstructorInvocation inv = new ConstructorInvocation(aopinfo, aopinfo.getInterceptors());
               inv.setArguments(getArguments());
               return inv.invokeNext();
               }
              ...
              


              • 4. Re: Intercepting ManagedComponent ctor
                Scott Stark Master

                The first call to a ManagedComponentImpl would be after the various bootstrap kernel deployments (bootstrap/*.xml of jboss AS) have been deployed and the ProfileServiceBootstrap runs. However, this class is referenced by a number of MC classes, so I'm not sure when its first loaded. Its probably when the bootstrap/deployers.xml ManagedObjectFactory bean is instantiated.

                Before another MainDeployer aspect was creating some of the ManagedObjects. That code is gone now.

                The question is whether I should be able to have an aspect in one of the bootstrap/*.xml deployments applied to the ManagedComponentImpl ctor?