Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Why no if-poincut for non-static expressions.



I recall Matthew Webster posting an answer to this one a while back....
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02107.html.

You can write the following which will achieve what you need:

aspect PushUntilPop pertarget(pushPop()){
...
 int state = 0;
 pointcut match(): set(* PushUntilPop.state) &&
 if(PushUntilPop.aspectOf(myTargetObject).state==2);
...
}


assuming you have 'myTargetObject' saved in the aspect state somewhere.

-- Adrian.
adrian_colyer@xxxxxxxxxx





10 August 2004 17:14
To: aspectj-dev@xxxxxxxxxxx
cc:
From: Eric Bodden <eric@xxxxxxxxx>
Subject: [aspectj-dev] Why no if-poincut for non-static expressions.




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

About the if-pointcut the AJ manual says:

"if(BooleanExpression)- Picks out each join point where the boolean
expression evaluates to true. The boolean expression used can only
access static members, variables exposed by teh enclosing pointcut or
advice, and thisJoinPoint forms. In particular, it cannot call
non-static methods on the aspect."

My question is: Why do we have this limitation to static members? Why
should it not be possible to e.g. check some field value of the
current aspect instance? In particular I would like the following to
work:

aspect PushUntilPop pertarget(pushPop()){
...
 int state = 0;
 pointcut match(): set(* PushUntilPop.state) && if(state==2);
...
}

The purpose is some kind of finite state machine: If the state of the
aspect is set to 2, I want to "accept" and thus want a pointcut that
captures that. Since the machine observes a specific target, I need
to associate one aspect instance with each such target (pertarget)
and cannot use static members.

Probably somebody could clarify this to me...

Cheers,
Eric

- --
Eric Bodden
RWTH Aachen University
ICQ UIN: 12656220, Skype: ericbodden, PGP: BB465582
Website: http://www.bodden.de

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQRjzTswiFCm7RlWCEQLQ8gCgrPfhw7IKcB9cc8eLvWc93qVBtzgAni1/
6/of30vJXivLUuto5NNZpOVm
=zrne
-----END PGP SIGNATURE-----


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
 http://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top