获取输入值到 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})

@无国籍 public class MrBean 实现 MrBeanRemote、MrBeanLocal {

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

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

所以如果我用 in = "print that" 调用打印方法,拦截器应该记录 "print that"。可能吗? 提前致谢

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