Java Reference
In-Depth Information
After clicking on Finish , our new custom scope is created, as shown in the
following code:
package com.ensode.cdiintro.scopes;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Scope;
@Scope // or @javax.enterprise.context.NormalScope
public @interface CustomScope {
To actually use our scope in our CDI applications, we would need to create a custom
context which, as mentioned previously, is primarily a concern for framework
developers and not for Java EE application developers. Therefore, it is beyond the
scope of this chapter. Interested readers can refer to JBoss Weld CDI for Java Platform ,
Ken Finnigan , Packt Publishing . (JBoss Weld is a popular CDI implementation and it is
included with GlassFish.)
In this chapter, we covered NetBeans support for CDI, a new Java EE API introduced
in Java EE 6. We provided an introduction to CDI and explained additional
functionality that the CDI API provides over standard JSF. We also covered how to
disambiguate CDI injected beans via CDI Qualifiers. Additionally, we covered how
to group together CDI annotations via CDI stereotypes. We also saw how CDI
can help us with AOP via interceptor binding types. Finally, we covered how
NetBeans can help us create custom CDI scopes.
Search WWH ::

Custom Search