Re: moving to codehaus - this list will be shut down

"jianxiong pang" <[email protected]> Mon, 12 May 2003 14:23:33 +0100
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Hi Honas,

I like aspectwerkz!

I think there is a bug in the transformation process. I write a simple
program to repeat the problem.
The problem is that an advice on a method in a class sometimes prevent
another advice on another method at the same class from being advised.
Please look the code below:

without aspects.
the output should be:

The discard method is runing
The send method is running

with aspect. The result should be

----discard advice happened here -----
The send method is running
----send advice happened here -----
discard method is running


but the result is now:

The discard method is runing
----send advice happened here -----
The discard method is runing
==========================================================
public class SendAdvice extends MethodAdvice {
      public SendAdvice() {
        super();
      }
    public Object execute(final JoinPoint joinPoint) throws Throwable {
         MethodJoinPoint jp = (MethodJoinPoint)joinPoint;
         SimpleState simple = (SimpleState)jp.getTargetObject();
         Object result = null;
        System.out.println("----send advice happened here -----");
        simple.discard();
        return result;
   }
}
============================================================
public class DiscardAdvice extends MethodAdvice {
      public DiscardAdvice() {
        super();
      }
    public Object execute(final JoinPoint joinPoint) throws Throwable {
         MethodJoinPoint jp = (MethodJoinPoint)joinPoint;
         SimpleState simple = (SimpleState)jp.getTargetObject();
         Object result = null;
         System.out.println("----discard advice happened here -----");
         simple.send();
         return result;
   }
}
===========================================================
public class Main {

     public static void main(String[] args) {
            SimpleState simple = new SimpleState();
            simple.feature(false);
            simple.feature(true);
     }
}
public class SimpleState {

     public void send() { //Typically, hand to MailHost.
       System.out.println("The send method is running");
      }
    public void feature(boolean runSend) {
         if(runSend)
            send();
         else
            discard();
    }
   public void discard() {
     System.out.println("The discard method is runing");
   }
}

===========================================================
<aspectwerkz>

 <advice name="onDiscard"
   advice="samples/examples/aspects/on_discard/DiscardAdvice"
       deploymentModel="perJVM"/>
 <advice name="onSend"
   advice="samples/examples/aspects/on_send/SendAdvice"
       deploymentModel="perJVM"/>

 <aspect class="samples.examples.core.bugshow.SimpleState">
  <pointcut type="method" pattern="discard">
   <advice-ref name="onDiscard"/>
  </pointcut>
 </aspect>
 <aspect class="samples.examples.core.bugshow.SimpleState">
  <pointcut type="method" pattern="send">
   <advice-ref name="onSend"/>
  </pointcut>
 </aspect>

</aspectwerkz>
================================================================

Cheers!

Jianxiong



-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com