January 17, 2021
Hot Topics:

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

  • 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

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

This article was originally published on January 27, 2011

Enterprise Development Update

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

Thanks for your registration, follow us on our social networks to keep up-to-date