Chapter 2. A first taste of EJB
This chapter covers
- The ActionBazaar application
- Stateless and stateful session beans in ActionBazaar
- Integrating CDI and EJB 3
- Persisting objects with JPA 2
In the age of globalization, learning a new technology by balancing a book on your lap while hacking away at a business problem on the keyboard has become the norm. Let’s face it—somewhere deep down you probably prefer this “baptism by fire” to trudging the same old roads over and over again. This chapter is for the brave pioneer in all of us, eager to peek over the horizon into the new world of EJB 3.
The first chapter gave you a 20,000-foot view of the EJB 3 landscape from a hypersonic jet. We defined EJB, described the services it offers and the EJB 3 architectural blueprint, and described how EJB 3 is related to CDI and JPA 2. This chapter is a low-altitude flyover with a reconnaissance airplane. Here we’ll take a quick look at the code for solving a realistic problem using EJB 3, JPA 2, and CDI. The example solution will use some of the EJB 3 component types, a layered architecture, and some of the services we discussed in chapter 1. You’ll see firsthand exactly how easy and useful EJB 3 is and how quickly you could pick it up.