@AspectJ 切入点,用于执行包的方法 [英] @AspectJ pointcut for execute methods of a package
问题描述
我想在特定的包中执行一个 execute 方法.
I want to execute a execute method in a specific package.
可能的切入点是什么?
注意:我使用的是@AspectJ 风格的 Spring AOP.
Note: I am using @AspectJ style Spring AOP.
推荐答案
看这里 http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html
@(org.xyz..*)
匹配任何带有注释的元素与类型模式 (org.xyz..*)
匹配的类型的注释.其他词,带有注释的带注释元素,该注释在org.xyz 包或子包.(括号是必需的这个例子).
@(org.xyz..*)
Matches any annotated element which has either an annotation of a type matching the type pattern(org.xyz..*)
. In other words, an annotated element with an annotation that is declared in the org.xyz package or a sub-package. (The parenthesis are required in this example).
所以你应该有以下 aop 配置:
So you should have the following aop config:
<aop:config>
<aop:advisor advice-ref="myAdvice" pointcut="execution(* com.mycompany..*(..))" order="1"/>
</aop:config>
和此建议的匹配 bean
and matching bean for this advice
<bean id="myadvice" class="com.mycompany.MyIntercetpor"/>
拦截器应该实现 org.aopalliance.intercept.MethodInterceptor
Interceptor should implement org.aopalliance.intercept.MethodInterceptor
这篇关于@AspectJ 切入点,用于执行包的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!