3 Replies Latest reply on Sep 19, 2005 10:35 AM by Tomasz Nazar

    AspectJ, Spring, Hibernate, JDO, etc... and JBAOP compatibil


      Hi there!

      There is some number of tools (frameworks) growing up that mess with *.class files, or do something else than simple on the sources. Some use custom class loader or whatever...

      I wonder: would it be possible to mix some (all?) of them among with JBossAOP compilers and would that work?!

      Of course the most interesting would be AspectJ. First [ajc] then [aopc] ;-) -- and I'm serious here!

      Anyone tried that? I know it is a matter of simple, few clicks and Ant's tasks (and I'll do that) -- but wanted to ask the experts first, this time.

      (I tried Spring & JBossAOP and for simple aspect they worked together, but one thing didn't work as I expected - maybe a bug of mine..).

      Tomasz Nazar

        • 1. Re: AspectJ, Spring, Hibernate, JDO, etc... and JBAOP compat
          Michael Frieß Newbie

          VERY interesting questions...

          Would be great to get some feedback here! Please. :-)

          • 2. Re: AspectJ, Spring, Hibernate, JDO, etc... and JBAOP compat
            Bill Burke Master

            JBoss AOP and AspectJ probably will not work with one another. I have not tried and would be interested if somebody did.

            Spring AOP is just dynamic proxies and not bytecode weaving so there should be no problems. JBoss AOP also has a dynamic proxy only framework, but we have not documented it until we finish integrating it with JBoss Microcontainer.

            • 3. Re: AspectJ, Spring, Hibernate, JDO, etc... and JBAOP compat

              Well Bill, :-) I just spent few hours doing that work!

              I am excited and I am the master ;)

              Here are the results:
              AspectJ CAN BE INTEGRATED together with JBossAOP.
              If no problems discovered in future then one could have the best of 2 AOP worlds.

              Will reference AspectJ as AJ and JBossAOP as JBAOP below

              Compilation process are easy 2 steps: [ajc] task first, then [aopc] task (using Ant).

              What did work for me (anything else not tried yet):

              environment: all using Java5, pre and post compilation. Not dynamic style.

              advice on the same pointcut: two different AOP frameworks' advice on the same method execution pointcuts worked! One specified and implemented with AJ (AJAspect.aj) and another specified (jboss-aop.xml) and implemented with JBAOP (JBossAOPAspect.java)
              I cannot see the use case for that (for now :) ), but the bytecode manipulation just worked. AspectJ bytecode processing (around advice) did almost none of processing to the method being adviced -- just a call to custom AJ method. Presumably that's why [aopc] could work on the processed bytecode :)

              Of course the method being adviced where specified using annotations:
              @pat.bo @pat.transaction->(..) -- in case of JBAOP
               execution(@pat.transaction * (@pat.bo *).*(..)); -- in case of AJ

              Introductions: mixins and simple interface introduction worked with JBAOP when at the same time I used AJ "inter-type" declarations (introductions).
              So, basically I achieved binary introductions with JBAOP somehow ;-D.

              AJ's declare errors: AJ's pointcut expression language can be used to declare warnings and errors. Basically this doesn't change the bytecode, so it should work anyhow.

              More to discover....

              I'll blog about that around Wednesday and also will provide sources for that.

              Tomasz Nazar