[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Guidaance on Cflow usage
|
Donal,
You are right; changing cflow() to cflowbelow() does not help.
You need to use the "&& !within(<Aspect>)" idiom to prevent
the infinite recursion. Modify your AddCflow() pointcut as
follows:
pointcut AddCflow(): cflow( execution( * WordCounter.Add( * )))
&& !within(Cflow);
This way the control-flow introduced by advice itself is not advised,
thus preventing the infinite recursion.
-Ramnivas
--- Donal Lafferty <laffertd@xxxxxxxxx> wrote:
> 1. Using cflowbelow does not help. In the example provided, the
> pointcut argument of the cflow designator does not explicitly match
> the
> advice in Cflow.aj. So, using cflowbelow should result in the same
> behaviour, and I get the same behaviour when I modify the pointcut to
> use cflow instead of cflowbelow.
>
> 2. Perhaps the behaviour I'm seeing is not a problem. Maybe cflow
> should match all join points during the execution, even if they are
> introduced by virtue of the same cflow call. In this light its okay
> that calls advice in Cflow.aj are caught.
>
> 3. If it is okay for advice statements of an aspect to match
> pointcuts
> in the same aspect, then I shouldn't have to use the mangled name to
> do
> it. Should I? If advice statements are legitimate join points, then
> I
> would expect to be able to use execution designators to pick them
> out.
> In a way I can, ex. call( * *.*( * )) seems to select calls to the
> advice in cflow.aj. However, given the claim that aspects are
> modelled
> on Java types, I would expect that something like call( * Cflow.*( *
> ))
> would also select advice from the aspect Cflow. Unfortunately it
> does
> not.
>
>
> DL
>
>
> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Ramnivas Laddad
> Sent: 16 August 2003 20:08
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Guidaance on Cflow usage
>
> Donal,
>
> You need to use cflowbelow() pointcut to exclude the join point
> itself.
>
> There is a sample chapter (chapter 3) from my book posted that
> covers control-flow based pointcuts:
> http://www.manning.com/laddad/
>
> -Ramnivas
>
> --- Donal Lafferty <laffertd@xxxxxxxxx> wrote:
> > Hi!
> >
> > I'm having trouble coming to grasps with cflow pointcuts. In the
> > example below, I was surprised to find out that cflow advice is
> > included
> > in the set of cflow join points, which leads to an infinite
> > recursion.
> > Although I'm tempted to submit this as a bug, I'm not wholly
> > convinced I
> > understand what I'm doing. Moreover, the bug submission system is
> > down.
> >
> > Any comments on the problem are more than welcome!
> >
> > Cheers,
> >
> >
> > DL
> >
> >
> > WordCounterDemo.java
> >
> > class WordCounterDemo
> > {
> > static String[] smallSample= {"This", "demos", "infinite",
> "loop",
> > "in",
> > "cflow", "before", "advice"};
> >
> > public static void main(String[] args) {
> > WordCounter wordCounter = new WordCounter();
> > String word;
> > String[] wordList1 = smallSample;
> > int words = 0;
> > for (int i = 0; i < wordList1.length; i++) {
> > word = smallSample[i];
> > System.out.println("Adding " + word +", as word #" +
> > (++words));
> > wordCounter.Add(word);
> > }
> > }
> > }
> >
> > WordCounter.java
> >
> > public class WordCounter {
> > public void Add(String word) {
> > System.out.println("Add entry, word = "+word.toString());
> > }
> > }
> >
> > Cflow.aj
> >
> > public aspect Cflow {
> > pointcut AddCflow(): cflow( execution( * WordCounter.Add( * )));
> >
> > // In AspectJ 1.0.6 and 1.1 here is an infinite loop here,
> because
> > the
> >
> > // before advice is itself considered a join point in the cflow.
> > before(): AddCflow() { System.out.println("Before advice call" );
> }
> > }
> >
> > CflowWeave.lst
> >
> > WordCounterDemo.java
> > WordCounter.java
> > Cflow.aj
> >
> >
> > Which compiles with:
> >
> > ajc -argfile CflowWeave.lst
> >
> > And runs with:
> >
> > java -classpatch "%CLASSPATH;./" WordCounterDemo
> >
> > Gives the output
> >
> > Adding This, as word#1
> > Exception in thread "main" java.langStackOverflowError
> >
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com