注释具有参数时Java EE CDI侦听器不工作

注释具有参数时Java EE CDI侦听器不工作,java,jakarta-ee,interceptor,java-ee-7,Java,Jakarta Ee,Interceptor,Java Ee 7,我想写一个CDI拦截器。如果我的注释只包含1个参数,截取效果很好,但是如果使用2个参数,截取就会中断。问题是为什么 拦截器类: @Monitored @Interceptor @Priority(APPLICATION) public class MonitoringInterceptor { @AroundInvoke public Object logInvocation(InvocationContext ctx) throws Exception {

我想写一个CDI拦截器。如果我的注释只包含1个参数,截取效果很好,但是如果使用2个参数,截取就会中断。问题是为什么

拦截器类:

@Monitored
@Interceptor
@Priority(APPLICATION)
public class MonitoringInterceptor {

    @AroundInvoke 
    public Object logInvocation(InvocationContext ctx) throws Exception {
        LOGGER.error("METHOD CALLED!!!"); //this is not called when annotation has 2 parameters
        return ctx.proceed();
    }
}
注释:

@InterceptorBinding
@Target({TYPE, METHOD})
@Retention(RUNTIME)
@Inherited
public @interface Monitored {
    public String layer() default "BUSINESS";
    public String useCase() default "N/A";
}
现在有趣的部分是:

@Stateless
public class MyBean {

    //this does not work, why?
    @Monitored(layer = "BUSINESS", useCase = "test")

    //if I use the following annotation it works well
    //@Monitored(layer = "BUSINESS")
    public String sayHello(String message) {
        return message; 
    }
}
我知道,
MyBean
没有使用
@拦截器进行注释。这是有意的。拦截器在
beans.xml
中声明:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
   bean-discovery-mode="all">
<interceptors>
    <class>my.package.MonitoringInterceptor</class>
</interceptors>
</beans>

my.package.MonitoringInterceptor

参数是绑定的一部分。用
@Nonbinding
注释参数,或者确保拦截器和拦截点使用相同的值。

在将
@Nonbinding
添加到参数后,谢谢。