目前正在开发应用了Schema-based AOP的项目,一直用在参考《spring开发参考手册》 在配置AOP的时候发现一些问题:
配置文件如下:
<aop:aspect id="prefixAspect3" ref="logInterceptor">
<aop:pointcut id="prefixPointCutQuery"
expression="execution(* services.OcsServices.query(Object, int, int)) and args(Object, int, int)" />
<!--
<aop:pointcut id="prefixPointCutQuery"
expression="execution(* services.OcsServices.query(Object, int, int)) and args(o, page, perpage)" />
-->
<aop:after-returning
pointcut-ref="prefixPointCutQuery"
returning="retVal"
method="afterAddReturn"/>
</aop:aspect>
</aop:config>
services.OcsServices.query方法如下:
public List query(Object o, int page, int perpage){
....
}
LogAop的afterAddReturn方法如下:
public void afterAddReturn(Object retVal){
System.out.println(retVal);
}
如果按照参考手册的例子来,expression="execution(* services.OcsServices.query(Object, int, int)) and args(o, page, perpage)"才是正确的配置,但是实际情况是这样配置,将报错aop warning no match for this type name o
而如果用expression="execution(* services.OcsServices.query(Object, int, int)) and args(Object, int, int)"则能正确使用aop, 不知这是什么原因?
还希望大大们能指导指导,谢谢
配置文件如下:
<aop:aspect id="prefixAspect3" ref="logInterceptor">
<aop:pointcut id="prefixPointCutQuery"
expression="execution(* services.OcsServices.query(Object, int, int)) and args(Object, int, int)" />
<!--
<aop:pointcut id="prefixPointCutQuery"
expression="execution(* services.OcsServices.query(Object, int, int)) and args(o, page, perpage)" />
-->
<aop:after-returning
pointcut-ref="prefixPointCutQuery"
returning="retVal"
method="afterAddReturn"/>
</aop:aspect>
</aop:config>
services.OcsServices.query方法如下:
public List query(Object o, int page, int perpage){
....
}
LogAop的afterAddReturn方法如下:
public void afterAddReturn(Object retVal){
System.out.println(retVal);
}
如果按照参考手册的例子来,expression="execution(* services.OcsServices.query(Object, int, int)) and args(o, page, perpage)"才是正确的配置,但是实际情况是这样配置,将报错aop warning no match for this type name o
而如果用expression="execution(* services.OcsServices.query(Object, int, int)) and args(Object, int, int)"则能正确使用aop, 不知这是什么原因?
还希望大大们能指导指导,谢谢