我想在特定包中执行execute方法。
这可能是一个可能的切入点?
注意:我使用的是@AspectJ风格的Spring AOP。
答案 0 :(得分:6)
在这里查看http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html
@(org.xyz..*)
匹配任何带有an的带注释元素 与类型模式(org.xyz..*)
匹配的类型的注释。其他 单词,带注释的带注释元素 org.xyz包或子包。 (括号内需要括号 这个例子)。
所以你应该有以下aop配置:
<aop:config>
<aop:advisor advice-ref="myAdvice" pointcut="execution(* com.mycompany..*(..))" order="1"/>
</aop:config>
并为此建议匹配bean
<bean id="myadvice" class="com.mycompany.MyIntercetpor"/>
拦截器应该实现org.aopalliance.intercept.MethodInterceptor