Enterprise JavaBeans 3

EJB internals

Although we’ve talked about the role of the container and the concept of managed services, we haven’t explained how most containers go about providing managed services. The secret to understanding these and the other EJB services is knowing how the container provides them. Without going into too much detail, we’ll discuss EJB objects—which perform the […]

Accessing resources using DI and JNDI (EJB 3)

We’ve seen EJB 3 DI in its primary incarnations already—the Ojavax.ejb.EJB and Ojavax.annotation.Resource annotations. EJB 3 DI comes in two more forms—the Ojavax.persistence.PersistenceContext and Ojavax.persistence.Persistence-Unit annotations. We’ll see these two annotations in action in part 3 of this topic. We’ve also witnessed only a small part of the power of the @Resource annotation. So far, […]

AOP in the EJB world: interceptors

Have you ever been in a situation in which your requirements changed toward the end of the project and you were asked to add some common missing feature, such as logging or auditing, for EJBs in your application? Adding logging code in each of your EJB classes would be time consuming, and this common type […]

Scheduling: the EJB 3 timer service

Scheduled tasks are a reality for most nontrivial applications. For example, your business application may have to run a daily report to determine inventory levels and automatically send out restocking requests. For most legacy applications, it is typical to have a batch job to clean up temporary tables at the start or end of each […]

Understanding transactions (EJB 3)

We engage in transactions almost every day—when withdrawing money from an ATM or paying a phone bill, for example. Transactions in computing are a closely related concept but differ slightly and are a little harder to define. In the most basic terms, a transaction is a grouping of tasks that must be processed as an […]

Container-managed transactions (EJB 3)

In a CMT, the container starts, commits, and rolls back a transaction on our behalf. Transaction boundaries in declarative transactions are always marked by the start and end of EJB business methods. More precisely, the container starts a JTA transaction before a method is invoked, invokes the method, and depending on what happened during the […]

Bean-managed transactions (EJB 3)

The greatest strength of CMT is also its greatest weakness. Using CMT, you are limited to having the transaction boundaries set at the beginning and end of business methods and relying on the container to determine when a transaction starts, commits, or rolls back. BMT, on the other hand, allows you to specify exactly these […]

Exploring EJB security

Securing enterprise data has always been a primary application development concern. This is especially true today in the age of sophisticated cyber-world hackers, phishers, and identity/data thieves. Consequently, security is a major concern in developing robust Java EE solutions. EJB has a security model that is elegant, flexible, and portable across heterogeneous systems. In the […]

Domain modeling and the JPA (EJB 3)

Often the first step to developing an enterprise application is creating the domain model—that is, listing the entities in the domain and defining the relationships between them. In this section we’ll first present a primer on domain modeling. Then we’ll explore the ActionBazaar problem domain and identify actors in a domain model, such as objects, […]

Implementing domain objects with JPA (EJB 3)

In the previous few sections you learned about domain modeling concepts and identified part of the ActionBazaar domain model. Also, we briefly introduced some commonly used metadata annotations supported by JPA. In this section, you’ll see some of the JPA annotations in action as we implement part of the domain model using the EJB 3 […]