• Post Reply Bookmark Topic Watch Topic
  • New Topic

A question about spring aop annotation.  RSS feed

 
Jack Robertson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following example,
Before("execution(* aop.x.Store.*(..))"+"&&target(store)")
public void sayHelloAspect(Store store){}

I purchased the membership from learnnowjava.com and the teacher said that the aspect will match if and only if the called method has a parameter of type Store, and it will be given the name "store" so it can be accessed in the sayHelloAspect() .

Here is my questions,
intuitively I assume the purpose to use target() is to get the target object of the method invocation ,that is,the bean .And if you only want to get the parameter in the called method, why not use args() instead of target()?
Does it mean that you can either get the target object of the method invocation(in this example ,the type of the parameter in sayHelloAspect() will be changed to Object) or get the arg of the declared type in the advice ? Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!