SpringAop 配置说明

  <!-- datasourceone 数据库事务管理切点   
       包含的方法:service包(或子包)下所有名字以 'Service' 结尾的类内所有的方法。  
       不包含的方法:x.y.service包下PublishService类的getResCategory(..)方法,  
       getEditorResList(..)方法,updateResbackrmd(..)方法  
  --> 
  <aop:pointcut id="txPointcut-datasourceone"   
    expression="execution(* x.y.service..*Service.*(..))   
      and !execution(* x.y.service.PublishService.getResCategory(..))   
      and !execution(* x.y.service.PublishService.getEditorResList(..))   
      and !execution(* x.y.service.PublishService.updateResbackrmd(..))"/> 


1,pointcut既可以定义在一个接口上面(表示实现该接口的类方法将被拦截),同时也可以定义在一个类上面(无接口的情
   况,需要强制使用cglib)。在接口上面定义pointcut时无需关心接口实现类的具体位置,只需要定义被拦截的接口及方
   法位置。

2,常见的情况:
x.y.service..*Service.*(..)
x.y.service —— 包“x.y.service”
x.y.service.. —— 包“x.y.service”及其子包例如:“x.y.service.abc”,“x.y.service.def”,“x.y.service.ghi”,“x.y.service.jkl”。。。
*Service —— 定义接口(或没有实现接口的类,需要使用cglib代理)表达式;所有以Service结尾的类或接口,注意不是所有以Service结尾的包名。
*(..) —— 定义方法名,方法参数表达式;任意方法的名称,任意方法参数。

com.xyz.service.*.*(..)
com.xyz.service —— 包“com.xyz.service”
*.*(..) —— 任意接口(或没有实现接口的类,需要使用cglib代理),任意方法,任意参数
在service包下定义的任意方法的执行。

com.xyz.service..*.*(..)
com.xyz.service —— 包“com.xyz.service”
com.xyz.service.. ——包“com.xyz.service”及其子包
*.*(..) —— 任意接口(或没有实现接口的类,需要使用cglib代理),任意方法,任意参数

猜你喜欢

转载自hwwlove.iteye.com/blog/2003697