声明环绕通知 博客分类: Spring 声明环绕通知spring aopaop:around
程序员文章站
2024-03-15 13:14:11
...
编写watchPerformance()
public void watchPerformance(ProceedingJoinPoint joinpoint) { try { System.out.println("take seat"); System.out.println("trun off phone"); long start = System.currentTimeMillis(); System.out.println(start); joinpoint.proceed(); long end = System.currentTimeMillis(); System.out.println(end); System.out.println("applaud"); System.out.println("spend time:"+(end-start)+"milliseconds"); } catch (Throwable e) { e.printStackTrace(); System.out.println("refund"); } }
配置文件
<aop:config> <aop:aspect ref="audience"> <aop:pointcut expression="execution(* *.perform(..))" id="a"/> <aop:around pointcut-ref="a" method="watchPerformance"/> </aop:aspect> </aop:config>
运行结果
上一篇: 进位计数法和不同进制数相互转换
下一篇: redis 安装