Lesson 31Introduction to Enterprise JavaBeans

This lesson introduces you to one of the Java EE technologies, Enterprise JavaBeans (JSR 345), which can be used for implementing the business tier in a distributed application (refer to Figure 25-1 in Lesson 25). Chapter 26 and Chapter 27 were about various ways of programming the presentation tier on the web; in Chapter 30 and Chapter 29 you learned how to organize communication between the different tiers of the application using messaging. The application business logic was programmed in POJOs.

In this lesson you see how to program the business tier in EJBs, which are also POJOs, but managed by an EJB container. Java EE 7 includes EJB 3.2 and the Java Persistence API (JPA) 2.1 that offer you a standardized way to implement solutions for business logic and data persistence. Using EJBs as JMS listeners makes your enterprise application more scalable without the need to write additional code.  

This lesson introduces you to various types of EJBs, and the next lesson is about persisting data with JPA. 

Who Needs EJB Containers?

What’s wrong with POJOs? Why not just implement business logic there? You certainly can, but most likely you’d need to spend additional time manually programming a multithreaded environment for them. The chances are that your application needs transactional support. If the business logic is located in POJO 1 and POJO 2, and the second one fails, you want to roll back whatever has been completed by the first ...

Get Java Programming 24-Hour Trainer, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.