CDI interceptor abstract

Context:

Wildfly 8.1.0 with CDI 1.2

According to the specification CDIfor CDI1.2you do not need to declare cdi in beans.xmlif it is annotated@Priority(somepriorityvalue)

However, the following cdi interceptors are never called unless I add an @Dependentannotation

@RequiresLoggedInAccount
@Interceptor
@Priority(Interceptor.Priority.APPLICATION)
public class MyInterceptor {

  @AroundInvoke
  public Object intercept(final InvocationContext ic) throws Exception {
    //intercept something and then...
    return ic.proceed();
  }
}

and interceptor binding:

@Inherited
@Documented
@InterceptorBinding
@Target({METHOD, TYPE})
@Retention(RUNTIME)
public @interface RequiresLoggedInAccount {
}

Note that interceptor binding and interceptor are defined in another jar module from which they are used (therefore the goal is for @Priority).

Did I forget something? Why should I add an area CDI @Dependentfor an interceptor to strike?

This is because I specifically indicated in beans.xml bean-discovery-mode="annotated"

+4
source share
1 answer

WildFly 8.1 Weld 2.1.x( x, 2.1 CDI 1.1). , Weld 2.2, CDI 1.2, .

, , CDI 1.1.

0

Source: https://habr.com/ru/post/1584093/


All Articles