⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hellointerceptor.java

📁 ejb3实例教程全部配书源码
💻 JAVA
字号:
package com.foshanshop.ejb3.impl;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;


public class HelloInterceptor {

    @AroundInvoke
    public Object log(InvocationContext ctx) throws Exception {
        System.out.println("*** HelloInterceptor intercepting");
        long start = System.currentTimeMillis();
        try{
            if (ctx.getMethod().getName().equals("SayHello")){
                System.out.println("*** SayHello 已经被调用! *** " );
            }            
            if (ctx.getMethod().getName().equals("Myname")){
                System.out.println("*** Myname 已经被调用! *** " );
            }            
            return ctx.proceed();
        }catch (Exception e) {
            throw e;
            
        }finally {
            long time = System.currentTimeMillis() - start;    
            System.out.println("用时:"+ time + "ms");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -