Java Reference
In-Depth Information
Qualiiers
In some instances, the type of bean we wish to inject into our code may be an
interface or a Java superclass, but we may be interested in injecting a subclass or
a class implementing the interface. For cases like this, CDI provides qualifiers we
can use to indicate the specific type we wish to inject into our code.
A CDI qualifier is an annotation that must be decorated with the @Qualifier
annotation. This annotation can then be used to decorate the specific subclass or
interface. In this section, we will develop a Premium qualifier for our customer bean;
premium customers could get perks that are not available to regular customers,
for example, discounts.
Creating a CDI qualifier with NetBeans is very easy; all we need to do is go to File
| New File , select the Contexts and Dependency Injection category, and select the
Qualifier Type file type.
 
Search WWH ::




Custom Search