10 Replies Latest reply on Apr 18, 2005 6:27 AM by ifrit

    [testing with AOP]

    ifrit

      Hi,

      i'm new with AOP, and with JBoss too. I'd like to test some applications in simulated time. For that i want to use JBoss AOP, i looked up for a week now, but i don't find a way to increase time speed in my application with AOP. If any one got an idea, i'd like to hear it.

      Thanks.

        • 1. Re: [testing with AOP]
          ifrit

          Well i'll add more to my request.

          What i'd like to do is replace call of new Date();
          with my own call of new Date(), that is a Date that is speed up.

          Is that realistic??

          • 2. Re: [testing with AOP]
            kabirkhan

            A constructor caller pointcut could help, the question is if the overhead of this is worth the performance increase of your Date class.

            Please take a look at the tutorial that comes with the AOP distribution :-)

            • 3. Re: [testing with AOP]
              ifrit

              well, i tried many things, but for the moment i can't intercept a constructor call.

              public class HelloAOP {
               public void callMe () {
               System.out.println("AOP");
               }
               /**
               *
               */
               public static void main (String args[] ) {
               new HelloAOP().callMe();
               }
              }
              


              jboss-aop.xml file
              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <aop>
               <!--aspect class="IOExceptionInjector" scope="PER_VM"/>
               <bind pointcut="call(* $instanceof{java.io.BufferedReader}->readLine()) AND within(HelloAOP)">
               <advice name="throwIO" aspect="IOExceptionInjector"/>
               <interceptor class="HelloAOPInterceptor"/>
               </bind-->
               <bind pointcut="call(*->new(..))">
               <interceptor class="HelloAOPInterceptor"/>
               </bind>
              </aop>
              


              import org.jboss.aop.advice.Interceptor;
              import org.jboss.aop.joinpoint.Invocation;
              
              public class HelloAOPInterceptor implements Interceptor {
              
               public String getName() {
              
               return "HelloAOPInterceptor";
               }
              
              
               public Object invoke(Invocation invocation) throws Throwable {
               System.out.println("Hello, ");
               return invocation.invokeNext();
               }
              }
              


              • 4. Re: [testing with AOP]
                kabirkhan

                Does the constructor tutorial work for you?

                • 5. Re: [testing with AOP]
                  ifrit

                  well, it may be some malfunction with eclipse, now i can do the interception. it works fine, but i still got a question, is it possible to intercept

                  public static void main(String [] args)
                  , for the moment by me it appears as it doesn't work.
                  I'd like to do that to initialize some variables at the start of application.

                  Thanks all.

                  • 6. Re: [testing with AOP]
                    ifrit

                    like the other one, it doens't work for the first tries, but now it works fine. So for the moment i don"t have other question about aop, but it may come when i may try the hot deployment.

                    See you later.

                    • 7. Re: [testing with AOP]
                      ifrit

                      lol, a question sooner than expected.

                      how do i write pointcut expression for tables arguments??

                      for example for the function main(String [] args)

                      java.lang.String [] isn't accepted

                      • 8. Re: [testing with AOP]
                        kabirkhan

                        It should work if you do

                        "execution(public static void blah.MyClass->main(java.lang.String[])"
                        


                        • 9. Re: [testing with AOP]
                          ifrit

                          yes it works, for the story, it was just a space beetwen String and [ that was the cause of the error, but if there is no space it works perfectly. maybe something to say in the doc.

                          • 10. Re: [testing with AOP]
                            ifrit

                            Is it possible to apply a point cut to an entire branch of packages, like for example

                            pointcut="..." and within(java.*)
                            for all class in package java and the subpackages aso.