From Spring Documentation:
any join point (method execution only in Spring AOP) where the proxy implements the AccountService interface:
this(com.xyz.service.AccountService)
any join point (method execution only in Spring AOP) where the target object implements the AccountService interface:
target(com.xyz.service.AccountService)
I don't understand what "target object" and the expression target(...)
mean.
How is target
different from this
?
this(AType)
means all join points where this instanceof AType
is true. So this means that in your case once the call reaches any method of AccountService this instanceof AccountService
will be true.
target(AType)
means all join points where anObject instanceof AType
. If you are calling a method on an object and that object is an instanceof AccountService, that will be a valid joinpoint.
To summarize a different way - this(AType)
is from a receivers perspective, and target(AType)
is from a callers perspective.