spring AspectJ order(顺序)
来源:互联网 发布:软件开发软件有哪些 编辑:程序博客网 时间:2024/05/10 19:23
@Aspect@Order(2)public class HelloWorldAspectAnnotation {/** * JoinPoint接口 * @param joinPoint *//*public interface JoinPoint { String toString(); //连接点所在位置的相关信息 String toShortString(); //连接点所在位置的简短相关信息 String toLongString(); //连接点所在位置的全部相关信息 Object getThis(); //返回AOP代理对象 Object getTarget(); //返回目标对象 Object[] getArgs(); //返回被通知方法参数列表 Signature getSignature(); //返回当前连接点签名 SourceLocation getSourceLocation();//返回连接点方法所在类文件中的位置 String getKind(); //连接点类型 StaticPart getStaticPart(); //返回连接点静态部分}*/ //定义前置通知,注意这里是sayHello2//使用@Before进行前置通知声明,其中value用于定义切入点表达式或引用命名切入点@Before(value="execution(* com.boventech..*.sayHello2(..))&& args(param)",argNames="param")public void beforeAdvice(JoinPoint joinPoint,String param) {System.out.println(1);System.out.println("=======================");System.out.println("===param:" + param);System.out.println("=======================");System.out.println(joinPoint.getArgs().length);System.out.println("=======================");System.out.println(joinPoint.toString());System.out.println("=======================");System.out.println(joinPoint.getTarget());System.out.println("=======================");System.out.println(joinPoint.getThis());System.out.println("=======================");System.out.println("===========before advice");}/*value:指定切入点表达式或命名切入点; pointcut:同样是指定切入点表达式或命名切入点,如果指定了将覆盖value属性指定的,pointcut具有高优先级;*/@AfterReturning(value="execution(* com.boventech..*.sayHello2(..))&& args(param)",argNames="param",pointcut="execution(* com.boventech..*.sayHello2(..))&& args(param)")public void afterFinallyAdvice(JoinPoint joinPoint,String param) {System.out.println("param:"+param);System.out.println("===========");System.out.println("===========after finally advice");}}
@Aspect@Order(1)public class HelloWorldAspectAnnotation2 {/** * JoinPoint接口 * @param joinPoint *//*public interface JoinPoint { String toString(); //连接点所在位置的相关信息 String toShortString(); //连接点所在位置的简短相关信息 String toLongString(); //连接点所在位置的全部相关信息 Object getThis(); //返回AOP代理对象 Object getTarget(); //返回目标对象 Object[] getArgs(); //返回被通知方法参数列表 Signature getSignature(); //返回当前连接点签名 SourceLocation getSourceLocation();//返回连接点方法所在类文件中的位置 String getKind(); //连接点类型 StaticPart getStaticPart(); //返回连接点静态部分}*/ //定义前置通知,注意这里是sayHello2//使用@Before进行前置通知声明,其中value用于定义切入点表达式或引用命名切入点@Before(value="execution(* com.boventech..*.sayHello2(..))&& args(param)",argNames="param")public void beforeAdvice(JoinPoint joinPoint,String param) {System.out.println(2);System.out.println("=======================");}/*value:指定切入点表达式或命名切入点; pointcut:同样是指定切入点表达式或命名切入点,如果指定了将覆盖value属性指定的,pointcut具有高优先级;*/@AfterReturning(value="execution(* com.boventech..*.sayHello2(..))&& args(param)",argNames="param",pointcut="execution(* com.boventech..*.sayHello2(..))&& args(param)")public void afterFinallyAdvice(JoinPoint joinPoint,String param) {System.out.println("order:" + 2);}}
public class AopAnnotationTest {@Test public void testHelloworld() { ApplicationContext ctx = new ClassPathXmlApplicationContext("/helloWorld2.xml"); IHelloWorld2Service helloworldService =ctx.getBean("helloWorld2Service", IHelloWorld2Service.class); String param = "12"; helloworldService.sayHello2(param); }}
<aop:aspectj-autoproxy/><bean id="helloWorld2Service" class="com.boventech.learning.serviceImpl.HelloWorld2ServiceImpl"/> <bean id="aspect" class="com.boventech.learning.aspect.HelloWorldAspectAnnotation"/> <bean id="aspect2" class="com.boventech.learning.aspect.HelloWorldAspectAnnotation2"/>
1 0
- spring AspectJ order(顺序)
- Spring-AOP @AspectJ进阶之增强织入的顺序
- Spring + AspectJ
- spring @AspectJ
- Spring切面通知执行的顺序(Advice Order)
- spring学习笔记(12)@AspectJ研磨分析[3]增强织入顺序实例详解
- Spring 与Aspectj集成
- spring AspectJ 基本使用
- Spring AOP + AspectJ framework
- spring中的aspectJ表达式
- Spring AOP与Aspectj
- spring mvc with aspectJ
- spring AspectJ aop学习
- Spring AspectJ注解
- spring AspectJ的Execution
- spring aop AspectJ
- Spring AOP + AspectJ annotation
- spring aspectj JoinPoint
- OpenCV数字图像处理(3) 镜像
- poj 3740 Easy Finding(Dancing Links)
- U盘装系统 常见BIOS设置技巧
- 删除一颗二叉树
- 电脑组装配置单及组装电脑图文详细教程
- spring AspectJ order(顺序)
- POJ_2299 Ultra-QuickSort【归并排序】
- Windows网络编程系列教程之四:Select模型
- NYOJ 352 数乌龟
- Linux 云服务器环境配置
- CF 96D Volleyball(最短路套最短路)
- 第1章 计算机网络体系结构-2015年考研核心考点命题思路解密-----计算机网络 考点1 计算机网络概述 选择题部分
- 将一颗二叉树转换成它的镜像
- hdu 4745 Two Rabbits(带思维的DP)