study notes for EJB 3 in action (I)

EJB 3 in Action

preface

The initial goal for EJB was to provide a simpler alternative to CORBA through components and framework benefits-but the component benefits were oversold.

The heavyweight inheritance-based programming model was abandoned in favor of POJO programming and the verbose XML descriptor was now out of the developer's way.

EJB 3 leaves behind the flawed Entity Beans model in favor of the lightweight Java Persistence API (JPA).


1. What's what in EJB3

In very straightforward terms, Enterprise JavaBean (EJB) is a platform for building portable, reusable, and scalable business applications using the Java programming language.

From a developer's point of view, an EJB is a piece of Java code that executes in a specialized runtime environment called the EJB container, which provides a number of component services.

EJB as Components
The real idea behind a component is that it should effectively encapsulate application behavior. The users of a component aren't required to know its inner workings. All they need to know is what to pass in what to expect back.

There are three types of EJB components: session beans, message-driven beans and entities. Session beans and message-driven beans are used to implement business logic in an EJB application, and entities are used for persistence.

EJB as Framework
Most server-side applications have a lot in common, including churning business logic, managing application state, storing and retrieving information from a relational database, managing transactions, implementing security, performing asynchronous processing, integrating systems, and so on.

Being able to support high-performance, fault-tolerant, scalable applications is an up-front concern for the EJB platform instead of being an after-thought.

You'll be able to count on moving your application to a distributed, clustered server farm by doing nothing more than a bit of configuration.

Layered architectures and EJB
EJB allows you to build application using two different layered architectures: the traditional four-tier architecture and domain-driven design (DDD).

The traditional four-tier layered architecture is not perfect. One of the most common criticisms is that it undermines the OO ideal of modeling the business domain as objects that encapsulate both data and behavior. Because the traditional architecture focuses on modeling  business processes instead of the domain, the business logic tier tends to look more like database-driven procedural application than an OO one. Since persistence-tier components are simple data holders, they look a lot like database record definitions rather than first-class citizens of the OO world.

DDD emphasizes that domain objects should contain business logic and should not just be a dumb replica of database record. Domain objects are known as entities in EJB 3.

Why choose EJB 3?
Ease of use
Integrated solution stack (JDBC, JavaMail, JTA, JMS, JAAS, JNDI, RMI)
Open Java EE standard
Broad vendor support (IBM, Oracle, JBoss, Geronimo)
Stable, high-quality code base
Clustering, load balancing, and failover
 

你可能感兴趣的:(ejb,action,components,application,asynchronous,transactions)