3 Replies Latest reply on Apr 1, 2004 12:29 PM by Bill Burke

    Precompilation+Field and Constructor pointcuts

    kado0002 Newbie

      Hello!
      It seems that the precompiler org.jboss.aop.standalone.Compiler has got problems with anonymous classes and inner Classes.
      I've got written a Class with two anonymous classes. If I use the precompiler to compile my classes I get always exceptions when I replace the anonymous classes by normal classes the precompiler runs.

      Other problems (or two questions):

      1) is it possible to intercept a field access for a local variable? I've tried it out but it my example doesn't work.
      2) is it possible in a ConstructorInvocation to get the object that the constructor creates? (Practically the same as Object mi = invocation.targetObject by a MethodInvoctaion);
      I think it should be possible by an after-advice (finally Block). I've tried that too, but it doesn't work too.

      Can you help me please






        • 1. Re: Precompilation+Field and Constructor pointcuts
          Bill Burke Master

           

          "kado0002" wrote:
          Hello!
          It seems that the precompiler org.jboss.aop.standalone.Compiler has got problems with anonymous classes and inner Classes.
          I've got written a Class with two anonymous classes. If I use the precompiler to compile my classes I get always exceptions when I replace the anonymous classes by normal classes the precompiler runs.


          How can I reproduce the error? I've tested with inner classes, but not anonymous. Can you send me a sample file? bill@jboss.org. THankms


          "kado0002" wrote:

          1) is it possible to intercept a field access for a local variable? I've tried it out but it my example doesn't work.


          No.

          "kado0002" wrote:

          2) is it possible in a ConstructorInvocation to get the object that the constructor creates? (Practically the same as Object mi = invocation.targetObject by a MethodInvoctaion);
          I think it should be possible by an after-advice (finally Block). I've tried that too, but it doesn't work too.


          If you want to access the constructed object, it is actually the object returned by invocation.invokeNext();

          Object constructedObject = invocation.invokeNext();
          




          • 2. Re: Precompilation+Field and Constructor pointcuts
            kado0002 Newbie

            I've tried it again with the Compiler and now it runs
            Probably I've made something wrong by my first try.
            I'm writing my Thesis (diploma) about AOP. First I used AspectJ and now JBossAOP since 2 weeks.
            And so I've another question!

            Is it possible to bind a pointcut to a constructor or method which is createt or called in an
            aspect class.

            Example:

            class AspectName{
            public Object constructorAdvice2(ConstructorInvocation invocation) throws Throwable{
             makePressure();
             press = (PressureSensorImpl) new fachcode.Nimbus1_0PressureSensor();
             return invocation.invokeNext();
            }
            }


            Can I bind an execution pointcut to the constructor fachcode.Nimbus1_0PressureSensor() and how can I make that?

            Can I also bind a caller pointcut to a method that is declared and called in an aspect class?

            Thank you for your efforts
            Karsten Doller

            • 3. Re: Precompilation+Field and Constructor pointcuts
              Bill Burke Master

               

              "kado0002" wrote:
              I've tried it again with the Compiler and now it runs
              Probably I've made something wrong by my first try.
              I'm writing my Thesis (diploma) about AOP. First I used AspectJ and now JBossAOP since 2 weeks.
              And so I've another question!


              Hey, feedback is most welcome! Anything you can post about usability, features you want, features you don't like, bugs, etc... post as a new topic on this forum. Also, any bug fixes, or features you want to implement are also welcome!

              "kado0002" wrote:

              Is it possible to bind a pointcut to a constructor or method which is createt or called in an
              aspect class.


              Yes, this should work. if it doesn't give me a yell on the forum.

              "kado0002" wrote:

              Example:

              class AspectName{
              public Object constructorAdvice2(ConstructorInvocation invocation) throws Throwable{
               makePressure();
               press = (PressureSensorImpl) new fachcode.Nimbus1_0PressureSensor();
               return invocation.invokeNext();
              }
              }


              Can I bind an execution pointcut to the constructor fachcode.Nimbus1_0PressureSensor() and how can I make that?

              Can I also bind a caller pointcut to a method that is declared and called in an aspect class?


              Yes, this should be possible as well! If not, let me know.

              These are the exceptions:

              http://jboss.org/wiki/Wiki.jsp?page=Notpointcutable

              Happy hunting!

              Bill