CDI-Interceptor:从拦截的方法获取参数

VWe*_*ber 1 java cdi

我有一个界面

@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE })
public @interface LoggingInterceptorBinding {

}
Run Code Online (Sandbox Code Playgroud)

和一个班级:

@LoggingInterceptorBinding
@Interceptor
public class LoggingInterceptor implements Serializable {

@AroundInvoke
public Object onMethodCall(InvocationContext context) throws Exception {
    try {
        System.out.println("Log before Method");
        return context.proceed();
    } finally {
        System.out.println("Log after Method");
    }

}
Run Code Online (Sandbox Code Playgroud)

和一个带注释的方法:

@LoggingInterceptorBinding
public void sayHello(String name)
Run Code Online (Sandbox Code Playgroud)

是否可以在拦截器"onMethodCalls"-method中从sayHello获取参数"name"?

Sot*_*lis 5

The InvocationContext interface has a getParameters() method that

Returns the parameter values that will be passed to the method of the target class. If setParameters() has been called, getParameters() returns the values to which the parameters have been set.