package com.kaka.aop; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; /** * 被监控的方法在被调用之前都会进入invoke方法 * * * @author kaka * */ public class HeartBeatAop implements MethodInterceptor{ @Override public Object invoke(MethodInvocation invocation) throws Throwable { /** * 监控heartBeat方法,在调用heartBeat方法之前和之后做一些其他操作 */ //1.获得被监控方法的参数列表,此时heartBeat方法还没有被调用,这时候就可以根据业务需求做一些其他的操作 Object[] arguments = invocation.getArguments(); System.out.println("heartBeat方法的参数是:"+arguments[0]); //2.调用heartBeat方法 Object result = invocation.proceed(); //3.方法结束后的一些操作 System.out.println("监控heartBeat结果:"+result); return result;//此处的返回值对应被监控方法的返回值 } }
最近下载更多
最近浏览更多
1358849392 LV21
1月22日
女王不该在山炮村养花 LV8
2023年4月6日
猴子蹲蹲 LV2
2023年4月6日
我就一大帅比
2023年2月16日
暂无贡献等级
00044304 LV6
2022年8月24日
wxh1234567 LV4
2022年1月17日
阿远远 LV8
2021年11月26日
cenj12700 LV5
2021年8月13日
likezhensan LV8
2021年7月22日
thecl1 LV1
2021年6月21日