Monday, November 12, 2018

"bean- discovery-mode" attribute for Contexts and Dependency Injection

Java EE 7 platform enables default CDI injection for all beans that explicitly contain a CDI scope annotation and EJBs. A new attribute, “bean- discovery-mode” attribute is added to beans.xml:
<beans xmlns= mode=all>
This attribute can take the following values:
  1. all: All types in the archive are considered for injection. 
  2. annotated: Only types with an explicitly declared CDI scope are considered for injection. 
  3. none: Disable CDI
By default, CDI interceptors are disabled and can be enabled and ordered via the @javax.interceptor.Interceptor.Priority annotation as shown:
public class LoggingInterceptor {
//. . . }
This can be done for decorators and alternatives too.