November 22, 2014
Hot Topics:

Java EE 6 Deployment Flexibility with CDI and the @Alternative Annotation

  • January 26, 2011
  • By Glen Kunene
  • Send Email »
  • More Articles »

CDI (Contexts and Dependency Injection) is an integral part Java EE 6. This powerful facility enables you to develop Java EE components with well-defined scopes that exist within the lifecycle of an application. CDI also allows you to inject Java EE components such as JSF managed beans.

In his JavaBoutique article Applying CDI and the @Alternative Annotation in Java EE 6 Applications, Anghel Leonard explains how to use the @Alternative annotation to configure your application for different deployments. He writes:

With CDI support (@Alternative annotation), you can package multiple beans that have the same injection point without errors -- you can apply the @Alternative annotation to more than one bean and specify the bean you want to use in the CDI beans.xml configuration file.

Leonard demonstrates how to use CDI and the @Alternative by walking through the development of a volleyball and tennis game. The application employs NetBeans 6.9, JDK 6 and GlassFish v3.

 

Read the full story at JavaBoutique:
Applying CDI and the @Alternative Annotation in Java EE 6 Applications


Tags: annotations, 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