Tuesday, October 4, 2011

Spring AOP execution PCD(Pointcut designator) execution expression

mostly,we use execution,here is the execution expression format

execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?)

pay attention to the space after question mark,and only ret-type-pattern is mandatory,after name-pattern,there is not space between name-pattern and bracket
for example:@Pointcut("execution(* transfer(..))")
means: start is for return type pattern,start means any type
transfer is for name-pattern,it means any method named transfer
two dots .. is parameter pattern,it means any number of parameter with any type
if we change it to (*),it mean one parameter with any type
(*,String) means two parameter with first one can be any type,second one must be String

No comments:

Post a Comment