AOP Examples
expression
1
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern) throws-pattern?)
examples
the execution of any public method
1
execution(public * *(..))
the execution of any method with a name beginning with “set”:
1
execution(* set*(..))
the execution of any method defined by the AccountService interface:
1
execution(* com.xyz.service.AccountService.*(..))
the execution of any method defined in the service package:
1
execution(* com.xyz.service.*.*(..))
the execution of any method defined in the service package or a sub-package:
1
execution(* com.xyz.service..*.*(..))
any join point (method execution only in Spring AOP) within the service package:
1
within(com.xyz.service.*)
any join point (method execution only in Spring AOP) within the service package or a sub-package:
1
within(com.xyz.service..*)
any join point (method execution only in Spring AOP) where the proxy implements the AccountService interface:
1
this(com.xyz.service.AccountService)
any join point (method execution only in Spring AOP) where the target object implements the AccountService interface:
1
target(com.xyz.service.AccountService)
any join point (method execution only in Spring AOP) which takes a single parameter, and where the argument passed at runtime is Serializable:
1
args(java.io.Serializable)
any join point (method execution only in Spring AOP) where the target object has an @Transactional annotation:
1
@target(org.springframework.transaction.annotation.Transactional)
any join point (method execution only in Spring AOP) where the declared type of the target object has an @Transactional annotation:
1
@within(org.springframework.transaction.annotation.Transactional)
any join point (method execution only in Spring AOP) where the executing method has an @Transactional annotation:
1
@annotation(org.springframework.transaction.annotation.Transactional)
any join point (method execution only in Spring AOP) which takes a single parameter, and where the runtime type of the argument passed has the @Classified annotation:
1
@args(com.xyz.security.Classified)
any join point (method execution only in Spring AOP) on a Spring bean named tradeService:
1
bean(tradeService)
any join point (method execution only in Spring AOP) on Spring beans having names that match the wildcard expression *Service:
1
bean(*Service)
留下评论