Chapter 5. EJB runtime context, dependency injection, and crosscutting logic

 

This chapter covers

  • The basics of the EJBContext
  • Using JNDI to look up EJBs and other resources
  • The @EJB annotation
  • EJBs in the application client and embedded containers
  • The basics of AOP interceptors

In the previous two chapters we focused on developing session beans and message-driven beans (MDBs). In this chapter we build on that material and introduce some advanced concepts applicable to MDBs and session beans. We begin by discussing how containers provide services behind the scenes and how to access the runtime environment. We then move on to advanced uses of dependency injection, JNDI lookups, and EJB interceptors. As you’ll learn, EJB 3 largely relieves you of these system-level concerns while providing extremely robust and flexible functionality when you need it.

5.1. EJB context

5.2. Using EJB DI and JNDI

Dependency injection pattern

Service locator pattern

5.3. AOP in the EJB world: interceptors

5.4. Summary