[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] identifying a call within a method and harvest the parameter
|
Robert,
At the call join point, the args pointcut matches the arguments to the called method, not the arguments to the enclosing execution join point. Note that withincode selects where a join point occurs but it doesn't correspond to a kind of join point. As Elizabeth suggests, you can use cflow to achieve what you want:
// a call in the cflow of a process call
pointcut creationInCflow(Parameter param):
cflow(execution(public Result Processor.process(Parameter)) &&
args(param)) &&
call(public Value Processor.createValue());
// a call that is occuring directly within the code of a process method, if that's
// really what you want
pointcut creationInProcess(Parameter param):
cflow(execution(public Result Processor.process(Parameter)) &&
args(param)) &&
withincode(public Result Processor.process(Parameter)) &&
call(public Value Processor.createValue());
Ron
Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895
> ------------Original Message------------
> From: robert kuzelj <robert_kuzelj@xxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Fri, Jun-18-2004 6:05 AM
> Subject: [aspectj-users] identifying a call within a method and harvest the parameter
>
> hi,
>
> i want to weave something around a call to a
> method where the result of the around advice is dependent
> on a paramater value given to the calling method.
>
> <code>
> public class Processor
> {
> public Result process(Parameter _param)
> {
> ...
> Value val = createValue();
> ...
> }
>
> public Value createValue()
> {
> return null;
> }
> }
> </code>
>
> now i want to do something like this
>
> <code>
> public aspect ProcessCreation
> {
> pointcut creation(Parameter _param):
> withincode(public Result Processor.process(Parameter))
> && args(_param)
> && call(public Value Processor.createValue());
>
> Value around(Parameter _param): creation(_param)
> {
> Value result = null;
> if (_param.getValue() == 0)
> {
> result = new Value("OK");
> }
> else
> {
> result = new Value("FAILED");
> }
> return result;
> }
> }
> </code>
>
> the problem is that as soon as i try to harvest the parameter
> from the surrounding method the advice gets not executed anymore
> (meaning the pointcut is not matched of course).
>
> anybody any idea?
>
> ciao robertj
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>