Skip to content

Latest commit

 

History

History
92 lines (58 loc) · 2.26 KB

File metadata and controls

92 lines (58 loc) · 2.26 KB

Interceptor binding types with members

Interceptor binding types may have annotation members.

@Inherited

@InterceptorBinding

@Target(\{TYPE, METHOD})

@Retention(RUNTIME)

public @interface Monitored \{

boolean persistent();

}

Any interceptor with that interceptor binding type must select a member value:

@Monitored(persistent=true) @Interceptor @Priority(2100)

public class PersistentMonitoringInterceptor \{

@AroundInvoke
 public Object
monitorInvocation(InvocationContext ctx)
throws Exception \{ ... }

}

The PersistentMonitoringInterceptor applies to this component:

@Monitored(persistent=true)

public class ShoppingCart \{ …​ }

But not to this component:

@Monitored(persistent=false)

public class SimpleShoppingCart \{ …​ }

Annotation member values are compared using the equals method.

Array-valued or annotation-valued members of an interceptor binding type are not supported. An extension specification may add support for these member types. For example the CDI specification See Jakarta Contexts and Dependency Injection (CDI specification) adds the jakarta.enterprise.util.Nonbinding annotation, allowing array-valued or annotation-valued members to be used on the annotation type, but ignored by the resolution process.

If the set of interceptor bindings of a component class or interceptor, including bindings inherited from CDI stereotypes See Jakarta Contexts and Dependency Injection (CDI specification) and other interceptor bindings, has two instances of a certain interceptor binding type and the instances have different values of some annotation member, the container automatically detects the problem, treats it as a definition error, and causes deployment to fail.