Aspect oriented question - Pointcut
i'm wondering what the following means in a pointcut
after(FigureElement 开发者_JS百科fe, int x, int y) returning:
call(void FigureElement.setXY(int, int))
&& target(fe)
&& args(x, y) {
System.out.println(fe + " moved to (" + x + ", " + y + ")");
}
what does target and args mean here? i've no idea.
Many thanks
Let's look to the AspectJ guide.
target(Type or Id) every join point when the target executing object is an instance of Type or Id's type
args(Type or Id, ...) every join point when the arguments are instances of Types or the types of the Ids
In your example, for pointcut to match, the method must be called on FigureElement instances and have two int arguments. Names given as target and args parameters means that those parameters are accessible inside your advice body.
So, your pointcut matches all calls to FigureElement.setXY method with two int arguments and gives you access to the matched instance as fe and method arguments as x and y.
加载中,请稍侯......
精彩评论