6 Replies Latest reply on Oct 15, 2004 4:56 PM by bill.burke

    Some questions/suggestions

    charles_blaxland

       

      "KevinConner" wrote:
      ....
      Think of my solution as the PrintWriter that surrounds the Writer ;-)


      E-e :/
      It is not correct type of comparition. But thanks for sample. Let's have a closer look at it, by first showing present state of JBossAOP API

      public void MyAspect
       extends KevinConnersNiceSolution //or/and additional configuration
      {
      
       Object firstAdviceBefore(...) //@@before
       Object firstAdviceAfter(...) //@@after
      }
      
      // and try to imagine that this class has only one! write method
      
      public java.io.Writer {
      void write(char[] cbuf)
       //Write an array of characters.
      abstract void close()
       //Close the stream, flushing it first.
      abstract void flush()
       //Flush the stream.
      }
      
      


      But true and useful Writer looks little different - it has write(String) method! (just like number of other methods which don't give you additional funcionallity but help you using other code)

      public java.io.Writer {
       void write(String str)
       //Write a string.
       void write(String str, int off, int len)
       //Write a portion of a string.void write(char[] cbuf)
      ...
      }
      
      // and the way I try to persuade you to
      
      public void MyAspect
      {
      
       @before Object firstPersistenceAdvice(...)
       @after Object secondAdviceAfter(...)
      
       Object standardAroundAdvice(..)...
      }
      


      And I'm sure you don't use this writer.write("Open your eyes") and System.out.println("And keep them opened") and you've written several emails to Sun complaining about Java API too big in this case

      ;)

      Yeah, nice to be on the second side of the mirror...

      Regards,
      Tomasz Nazar



        • 1. Re: Some questions/suggestions
          bill.burke

           

          "charles_blaxland" wrote:
          I've been writing some aspects with JBoss AOP and I like it a lot so far :)

          Some questions/suggestions:

          - The "within" scope limiter doesn't seem to work with field/set/get pointcuts? Should it?



          I'll add this to the list. So, the answer is no, it doesn't work right now.


          - It appears that you can't refer back to a previously defined typedef when defining an introduction? (ie: in a similar way to how you can refer back to a previous pointcut definition when defining an interceptor). What I would like to write is:
           <typedef name="FooTypes" expr="class(com.acme.foo.*)"/>
           <typedef name="BarTypes" expr="class(com.acme.bar.*)"/>
           <introduction expr="FooTypes OR BarTypes">
           ...
           </introduction>
          

          But this doesn't seem to work.


          looks like a bug. We'll get on it.



          - The library I'm writing (persistence framework of sorts) relies on both an interceptor and a mixin being applied to every class that will be made persistent. I want to simplify the setup of this as much as possible for the end user of my library. Ideally, all they would have to specify is a list of classes they want to persist, and my system handles setting up the appropriate jboss pointcuts and introductions programatically. I want to avoid the user having to mess around with jboss-aop.xml if possible.

          Although I haven't tried it yet, I think pluggable-pointcuts will let me mostly achieve what I want. However they don't go quite far enough, in that you can't have pluggable introduction typedefs. So what I'm suggesting is <pluggable-typedef> element that behaves in much the same way as pluggable-pointcut. Thoughts?


          Sounds like a good idea. I think we can implement this.


          - It would be useful if all fields and methods introduced into a class by JBoss AOP had some kind of unambiguous token in their name so they can be easily picked out when using reflection. At the moment most of them have "aop$" in their name, but not all.


          Does this work for you???

          http://docs.jboss.org/aop/aspect-framework/misc/reflection.html

          Bill

          • 2. Re: Some questions/suggestions
            charles_blaxland

            Great, thanks Bill!

            "Bill Burke" wrote:

            Does this work for you???

            http://docs.jboss.org/aop/aspect-framework/misc/reflection.html


            Cool - this is very nice and will do exactly what I want :-)

            Out of curiosity, is there much overhead in adding global call/field pointcuts (ie: not limited by a "within" or similar)? I'd imagine this would require crawling the bytecode of every class loaded, which sounds expensive (although I'm not familiar with what you can do with Javassist, so maybe this is not so bad as it sounds?).

            Thanks,
            Charles


            • 3. Re: Some questions/suggestions
              bill.burke

              If you use load time transformation, then yes, it is definately more expensive to have caller pointcuts although I haven't done any measurements. If you use the AOP precompiler, doesn't really matter how slow it is...

              Bill

              • 4. Re: Some questions/suggestions
                bill.burke

                BTW, feel free to advertise the aspects you are writing on our WIKI.

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

                Bill

                • 5. Re: Some questions/suggestions
                  kabirkhan

                  Hi there,

                  Regarding this:

                  "charles_blaxland" wrote:

                  - It appears that you can't refer back to a previously defined typedef when defining an introduction? (ie: in a similar way to how you can refer back to a previous pointcut definition when defining an interceptor). What I would like to write is:
                   <typedef name="FooTypes" expr="class(com.acme.foo.*)"/>
                   <typedef name="BarTypes" expr="class(com.acme.bar.*)"/>
                   <introduction expr="FooTypes OR BarTypes">
                   ...
                   </introduction>
                  

                  But this doesn't seem to work.



                  In RC2 this works:
                   <typedef name="FooTypes" expr="class(com.acme.foo.*)"/>
                   <introduction class="$typedef{FooTypes}">
                   <interfaces>
                   java.io.Serializable
                   </interfaces>
                   </introduction>
                  


                  I've just added to cvs the ability to do:

                   <typedef name="FooTypes" expr="class(com.acme.foo.*)"/>
                   <typedef name="BarTypes" expr="class(com.acme.bar.*)"/>
                   <introduction expr="class($typedef{FooTypes}) OR class($typedef{BarTypes})">
                   <interfaces>
                   org.jboss.test.aop.basic.EmptyInterface
                   </interfaces>
                   </introduction>
                  



                  Hope this helps.

                  Cheers,

                  Kabir


                  • 6. Re: Some questions/suggestions
                    bill.burke

                    On "within" + get/set. This is not possible. We will look to adding this after the 1.0 release.