timerinterceptor.java

来自「想学习EJB的同学」· Java 代码 · 共 27 行

JAVA
27
字号
/* * 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 + =
减小字号Ctrl + -
显示快捷键?