November 26, 2014
Hot Topics:

End Ambiguous Dependencies Errors with CDI Qualifiers

  • March 17, 2011
  • By Glen Kunene
  • Send Email »
  • More Articles »

Java EE 6 introduced Contexts and Dependency Injection (CDI) largely to facilitate typesafe dependency injection. In particular, CDI qualifiers -- Java annotations that are themselves annotated with the @javax.inject.Qualifier meta-annotation -- address the ambiguous injection dependencies errors that occur when you need more than one instance of a bean type. Qualifiers annotate bean types and injection points that differentiate between types.

In his Java Boutique article CDI Qualifiers: Java EE 6 Annotations to End Ambiguous Dependencies, Leonard Anghel explains the following types of qualifiers, as well as how to work with multiple qualifiers:

  • built-in qualifiers
  • qualifiers defined by user
  • qualifiers with members

He summarizes the value of qualifiers this way:

...when you need more than one bean that implements the same bean type, you can qualify an injection point to specify exactly which bean must be injected.

Read the full story at JavaBoutique:
CDI Qualifiers: Java EE 6 Annotations to End Ambiguous Dependencies


Tags: Dependency injection, Java EE 6, CDI

Originally published on http://www.developer.com.


Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel