繁体   English   中英

获取输入值到ejb 3.1抛出拦截器

[英]Get input value to ejb 3.1 throw interceptor

您是否知道有什么方法可以记录,抛出拦截器,被调用方法的输入值?

我实际的拦截器是

public class Interceptor {
@AroundInvoke
public Object interceptor(InvocationContext invocationcontext) throws Exception{
    //Stampa prima del metodo
    long startTime = System.currentTimeMillis();
    log.debug("Invoked method: "+invocationcontext.getMethod().getName());
    //here I would like to log also parameters. 
    try{
        return invocationcontext.proceed();
    } finally{
        log.debug("End of method: " + invocationcontext.getMethod().getName());
        log.debug(" duration: " + (System.currentTimeMillis() - startTime));
    }
}
}

豆是

@Interceptors({Interceptor.class})

@Stateless公共类MrBean实现MrBeanRemote,MrBeanLocal {

/**
 * Default constructor. 
 */
public MrBean() {       
}

public void print(String in){
    System.out.println("Print: " + in);
}
}

因此,如果我使用in =“ print that”调用print方法,则拦截器应记录“ print that”。 可能吗? 提前致谢

您要记录方法的参数,因此可以在InvocationContext上使用getParameters()方法: http : //docs.oracle.com/javaee/6/api/javax/interceptor/InvocationContext.html#getParameters()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM