What behavior are you trying to achieve?
When @tag methods run, Print hello and
then “smthng “+s?
When @tagBis methods run, just print “smthngs
“+s?
How does the second argument factor in
here?
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of mouna SAHIB
Sent: Wednesday, May 03, 2006 6:03
AM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users]
COmbining pointcuts in the same advice
Euh, my problem then is
to access to the two arguments of the two pointcuts! What I presented inthe
example doesn't match.
2006/5/3, mouna SAHIB < mouna.sahib@xxxxxxxxx>:
Okay, here is my exmaple:
The target class with 2 methods annotated by @tag and @tagBis:
package HelloWorld;
public class HelloWorld {
@tag(value = "mamethode")
public void sayHello( String s){
s = "sayHello";
System.out.println(s);
}
@tagBis
public void say(String s){
System.out.println("say" +s);
}
public static void main(String[] args) {
new
HelloWorld().sayHello(null);
new HelloWorld().say("a
call to say()");
}
}
and my aspect:
public aspect World {
private pointcut sayWorld(String s):execution(@tag *
*(..))&& args(s);
after(String s): sayWorld(s) {
System.out.println("World!");
}
private pointcut saySmthg(String s):execution(@tagBis *
*(..))&& args (s);
after(String s): saySmthg(s)&& sayWorld(s) {
System.out.println("smthg" +
s);
}
}
The two poitncuts have here the same type of arguments and I would like to
treat the two the same way (here a simple System.out.println("smthg"
+ s);)
All in all, I would like to advise the first pointcut by the second to add an
other treatement, envetually the one made with the second poitncut;
I hope I'm clear and excuse me expressing with a bad english ...
2006/5/3, Ron Bodkin < rbodkin@xxxxxxxxxxxxxx>:
Mouna,
If you use || then you aren't guaranteed to have access to
arguments from p2. Maybe you could post a concrete example of what you're
trying to achieve.
Subject: Re:
[aspectj-users] COmbining pointcuts in the same advice
but thisJoinPoint.getArgs() gives only arguments of
the pointcut p1()!
Is there a posiblity to have access to argumets of both p1 and p2? Because I
want to croscut the two bby the same code advice,and should for this manipulate
the arguments of the pne and the other!
2006/5/3,
Ron Bodkin <rbodkin@xxxxxxxxxxxxxx
>:
Mouna,
You can use p2(*) or p2(Type) to use the pointcut without
binding. However, if you want to use t2 in the body of your advice you need to
bind it. It can be possible to use thisJoinPoint.getArgs() to get arguments, or
perhaps (p2(*) || p1(*)) && args(t) if you want the single argument in
either case.
Hi all,
I have some pointcuts in my aspect:
pointcut p1(<argumentType t>): execution (...) && args(t);
after(<argumentType t>): p1(t){
//some code
}
pointcut p2(<argumentType t2>): execution (...) && args(t2);
after(<argumentType t2>): p2(t2){
//some code
}
and would rather like to do something like this:
pointcut p2 (<argumentType t2>): execution(...)&& args(t2);
after() : p2(t2) || p1(<argumentType t>){
//some code
}
but I don't kknow how to declare arguments in the pointcut and advice in this
case!
If I do like above, I can't use t2 in the advice body ! What can I do it
please?
Thanks for suggestion
Mouna
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
|