@AspectJ切入点,用于包的执行方法 [英] @AspectJ pointcut for execute methods of a package

查看:95
本文介绍了@AspectJ切入点,用于包的执行方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在特定程序包中执行execute方法.

I want to execute a execute method in a specific package.

这可能是切入点吗?

注意:我正在使用@AspectJ样式的Spring AOP.

Note: I am using @AspectJ style Spring AOP.

推荐答案

在这里看看

@(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆