📄 timerinterceptor.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package ejb3.day6;import javax.interceptor.AroundInvoke;import javax.interceptor.InvocationContext;/** * * @author user */public class TimerInterceptor { @AroundInvoke public Object timer(InvocationContext ic) throws Exception{ String bean = ic.getTarget().getClass().getName(); String method = ic.getMethod().getName(); long begin = System.currentTimeMillis(); Object ret = ic.proceed(); long end = System.currentTimeMillis(); System.out.println("calling " + method + " on " + bean + " takes " + (end - begin) + "ms"); return ret; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -