13 Replies Latest reply on May 28, 2006 4:30 PM by kabirkhan

    JBAOP-80 AOPJoinpointFactory

      AFAIK, this is largely done in terms of features?
      I've got a FIXME in the MC bootstrap to remove some hardwiring.

      The main thing to do is test it thoroughly.
      This includes the decision table I drew up in Neuchatel:

      Not Advised + No instance specific metadata = POJO
      Not Advised + Instance specific metadata = Proxy
      Not Advised + Instance specific introductions = Proxy
      Advised + No instance specific metadata = Class Advised POJO
      Advised + Instance specific metadata = Instance Advised POJO
      Advised + Instance specific introductions = Proxy "replaces Advisor" for POJO

      The other features that need testing are:

      * Constructor advices are invoked properly
      * The "hollow" stuff works such that you can create a JMX decorator
      for a POJO that doesn't actually exist yet because it is "on demand".

        • 1. Re: JBAOP-80 AOPJoinpointFactory

          I think it also needs some tests for things like a super class being
          advised or not advised and how that interacts with the proxy usage.

          • 2. Re: JBAOP-80 AOPJoinpointFactory

            I've added basic subtasks for each of the issues above
            http://jira.jboss.com/jira/browse/JBAOP-80
            to
            http://jira.jboss.com/jira/browse/JBMICROCONT-71

            Feel free to add more if you can think of anything.

            I've deferred the JSR77 stuff until after the 2.0.0M1 release
            because this really needs doing alongside the profile service.

            • 3. Re: JBAOP-80 AOPJoinpointFactory
              kabirkhan

              From JBAOP-80


              AOP should expose itself through the JoinPointFactory
              in particular the invocations should implement the JoinPoint interface


              Do we really want to do this? I'm thinking about "the the invocations should implement the JoinPoint interface" bit.
              What is wrong with the way it works at the moment?

              • 4. Re: JBAOP-80 AOPJoinpointFactory
                kabirkhan

                Obviously it does not work the way it is meant to at the moment, but can the AOPConstructorJoinPoint not instantiate the ConstructorInvocation?

                • 5. Re: JBAOP-80 AOPJoinpointFactory
                  kabirkhan

                   

                  "adrian@jboss.org" wrote:

                  Advised + Instance specific metadata = Instance Advised POJO


                  I think this should result in a proxy? Metadata is read from the advisor the same as annotations, and could cause an introduction to happen. The others look fine

                  • 6. Re: JBAOP-80 AOPJoinpointFactory

                     

                    "kabir.khan@jboss.com" wrote:
                    From JBAOP-80


                    AOP should expose itself through the JoinPointFactory
                    in particular the invocations should implement the JoinPoint interface


                    Do we really want to do this?


                    Not really, but It depends.
                    This was an old requirement that is not necessary now.
                    The idea was that a JoinPoint was a sort of skeleton Invocation
                    that the MC could retrieve and fire already detype requests at
                    like the Method.invoke() in Reflection or the ClassInfo abstraction.

                    • 7. Re: JBAOP-80 AOPJoinpointFactory
                      kabirkhan

                      I have added some tests for JBAOP-227 to test the decision matrix, they are under org.jboss.test.microcontainer.matrix in the aop-mc-int module.

                      As mentioned previously I have

                      Advised + Instance specific metadata -> Instance advised Proxy

                      (not instance advised POJO) since metadata could cause an introduction to happen.

                      If this is not ok, I could perhaps have the proxy factory check if the metadata in fact does cause extra interface introductions and create a proxy as needed? Your call :-)

                      • 8. Re: JBAOP-80 AOPJoinpointFactory
                        kabirkhan


                        I've got a weird scenario taking place in the inheritance tests for JBAOP-229. Basically if I do:

                        -aop.xml:

                         <bind pointcut="execution(* @org.jboss.test.microcontainer.support.Test->*(..))">
                         <interceptor-ref name="org.jboss.test.microcontainer.matrix.TestInterceptor"/>
                         </bind>
                        


                        bean.xml:

                        
                         <bean name="ProxiedChild" class="org.jboss.test.microcontainer.matrix.Child">
                         <annotation name="org.jboss.test.microcontainer.support.Test"/>
                         </bean>
                        


                        public class Child extends Base
                        {
                         public static boolean childInvoked;
                         public void childOnly()
                         {
                         childInvoked = true;
                         }
                        
                         public void baseOverridden()
                         {
                         childInvoked = true;
                         }
                        }
                        
                        public class Base
                        {
                         public static boolean baseInvoked;
                         public void baseOnly()
                         {
                         baseInvoked = true;
                         }
                        
                         public void baseOverridden()
                         {
                         baseInvoked = true;
                         }
                        
                         public void setProperty(int i)
                         {
                         baseInvoked = true;
                         }
                        }
                        


                        I get interception taking place for methods only existing in Base (baseOnly()) when generating an instance proxy for the Child class, since as far as it is concerned the current advisor it is matching on has been annotated with the @Test annotation. Since this annotation is introduced via the metadata context stored in the advisor there is no way to check if Base or Child is the class that has actually been annotated, the annotation applies to the whole bean, not the class.

                        I can probably work around this, question is what is the desired behaviour? The alternative would be to have the annotation only apply to the Child class and the pointcut
                        execution(* @org.jboss.test.microcontainer.support.Test->*(..))

                        would then only pick out the methods defined on the Child class itself.


                        If left as-is, one could narrow down what is intercepted by (same bean.xml as before)

                         <introduction class="@org.jboss.test.microcontainer.support.Test">
                         <interfaces>org.jboss.test.microcontainer.matrix.ChildInterface</interfaces>
                         </introduction>
                        
                         <bind pointcut="execution(* $instanceof{org.jboss.test.microcontainer.matrix.ChildInterface}->$implements{org.jboss.test.microcontainer.matrix.ChildInterface}(..))">
                         <interceptor-ref name="org.jboss.test.microcontainer.matrix.TestInterceptor"/>
                         </bind>
                        


                        public interface ChildInterface
                        {
                         void childOnly();
                         void baseOverridden();
                        }
                        


                        which would only pick out the Child.childOnly() and Child.baseOverridden() methods.

                        • 9. Re: JBAOP-80 AOPJoinpointFactory
                          kabirkhan

                          I get the opposite scenario from with a real annotation

                          @Test
                          public class Child extends Base
                          {
                           public static boolean childInvoked;
                           public void childOnly()
                           {
                           childInvoked = true;
                           }
                          
                           public void baseOverridden()
                           {
                           childInvoked = true;
                           }
                          }
                          


                          In this scenario
                          execution(* @org.jboss.test.microcontainer.support.Test->*(..))
                          


                          will not pick out Base.baseOnly(). This is similar to how "real" AOP works, although once the generated advisor weaving for AOP 2.0 is finalized it will be possible actually match on this.

                          I think it should be consistent whether we are advising with a proxy or a woven class - question is what way to go?

                          • 10. Re: JBAOP-80 AOPJoinpointFactory

                            This

                            <bean name="ProxiedChild" class="org.jboss.test.microcontainer.matrix.Child">
                             <annotation name="org.jboss.test.microcontainer.support.Test"/>
                             </bean>
                            


                            Should behave the same as this:

                            @Test
                            public class Child extends Base
                            


                            But only for that one instance of the bean.

                            • 11. Re: JBAOP-80 AOPJoinpointFactory
                              kabirkhan

                              OK,

                              The problem is the "behave the same" bit. With the current weaving mode that is used by default, the proxies do not behave like AOP as is stands right now. But with the AOP 2 weaving mode, AOP will behave like the the proxies.

                              A major feature of AOP 2, along with the full-blown per instance API, is the ability to specify interceptors for inherited methods.

                              There are still a few issues left before it is possible to make the new weaving mode the default. My understanding is that they should behave the same for no other reason than that they should be interchangable?

                              • 12. Re: JBAOP-80 AOPJoinpointFactory

                                Correct.

                                • 13. Re: JBAOP-80 AOPJoinpointFactory
                                  kabirkhan

                                  I've got all the pure aop stuff passing now using the new weaving mode (http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3947214#3947214)

                                  I still need to resolve creating an instance proxy for an already advised class using the new weaving mode before I can do the switch and add to these tests as outlined above.