CDI Extensions - Add Interceptors in ProcessAnnotatedType phase

前端 未结 1 1027
臣服心动
臣服心动 2021-01-16 10:09

I am trying to add an interceptor programatically. The interceptor is called LogginInterceptor and just logs the name of method it runs on. When using it with annotation @In

1条回答
  •  囚心锁ツ
    2021-01-16 10:38

    It's better to add the annotation-instance to the whole bean via AnnotatedTypeBuilder#addToClass. Don't forget to enable the interceptor per archive (via beans.xml) or globally via @javax.annotation.Priority. You can even create an instance of it dynamically and add it to your interceptor-implementation class (which is annotated with @Interceptor). Without that your @InterceptorBinding can't work at all.

    0 讨论(0)
提交回复
热议问题