[英]Get input value to ejb 3.1 throw interceptor
Do you know if there is any way to log, throw an interceptor, the input values of the called method? 您是否知道有什么方法可以记录,抛出拦截器,被调用方法的输入值?
my actual interceptor is 我实际的拦截器是
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));
}
}
}
The bean is 豆是
@Interceptors({Interceptor.class})
@Stateless public class MrBean implements MrBeanRemote, MrBeanLocal { @Stateless公共类MrBean实现MrBeanRemote,MrBeanLocal {
/**
* Default constructor.
*/
public MrBean() {
}
public void print(String in){
System.out.println("Print: " + in);
}
}
So if i call the print method with in = "print that" the interceptor should log "print that". 因此,如果我使用in =“ print that”调用print方法,则拦截器应记录“ print that”。 Is it possible?
可能吗? Thanks in advance
提前致谢
您要记录方法的参数,因此可以在InvocationContext上使用getParameters()方法: http : //docs.oracle.com/javaee/6/api/javax/interceptor/InvocationContext.html#getParameters()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.