Java Reference
In-Depth Information
Chapter 4. Learning
Context
Dependency Injection
Chapter 3 , Beginning Java EE 6 - EJBs , was a challenging chapter, since we had
to cover lots of ground, including Java Enterprise enhancements and Maven-specific
configuration. If you are still a Maven non-believer, in this chapter, we will give you
one more chance to embrace this amazing framework.
This chapter discusses Contexts and Dependency Injection ( CDI ), which is a new
addition to the Java EE specification as of Java EE 6. It provides several benefits that
were missing to Java EE developers, such as allowing any JavaBean to be used as a
JSF managed bean, including stateless and stateful session beans.
Some of the topics covered in this chapter include:
• What is Context Dependency Injection and how it relates to EJB
• How to rewrite our Ticket Booking example to use CDI and Java Server
Faces technology
• How to run the project using Maven
This chapter assumes familiarity with Java Server Faces ( JSF ), which will be used
to provide a graphical interface to our applications. If you are looking for a startup
guide for JSF, there are several excellent resources online about JSF, including the
relevant sections in the official Java EE 6 tutorial at http://docs.oracle.com/javaee/6/
tutorial/doc/bnatx.html .
Introducing Context and Dependency
Injection
Contexts and Dependency Injection for the Java EE platform introduces a standard
set of component management services to the Java EE platform.
As a component of Java EE 6, CDI is in many ways a standardization of concepts
that have been brewing in Spring for a long time, such as dependency injection and
interceptors. In fact, CDI and Spring 3 share many similar features.
Search WWH ::




Custom Search