Book Image

Java EE 7 Development with WildFly

Book Image

Java EE 7 Development with WildFly

Overview of this book

Table of Contents (21 chapters)
Java EE 7 Development with WildFly
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Learning Context and Dependency Injection

We saw that Chapter 3, Introducing Java EE 7 – EJBs, was challenging since we had to cover lots of ground, including Java Enterprise enhancements and a Maven-specific configuration. In this chapter, we'll discuss Contexts and Dependency Injection (CDI), which was added to the Java EE specification in Java EE 6 (starting from JSR 299). It provides several benefits to Java EE developers that were missing, such as allowing any JavaBean to be used as a JSF managed bean, including stateless and stateful session beans. You can find more information on CDI and the newest version of the specification itself (JSR 346) at http://www.cdi-spec.org/.

Some of the topics that will be covered in this chapter are as follows:

  • What Contexts and Dependency Injection is and how it relates to EJB

  • How to rewrite our ticket-booking example to use the CDI and JavaServer Faces technology

  • How to run the project using Maven

This chapter assumes familiarity with JavaServer...