Java 2004 — A Tour for the Midrange Developer

G

J2EE Overview

Next

Enterprise JavaBeans

Enterprise JavaBeans are server-side, modular, and reusable components that comprise specific units of functionality. EJBs are subject to special restrictions and must provide specific interfaces for container and client use and access. In addition, they can only run properly in an EJB container, which manages and invokes specific life cycle behavior. EJB components are appropriate when the application design requires scalability, transactional processing, and/or availability to multiple client types.

  • Session beans — may be either stateful or stateless, and are primarily used to encapsulate business logic, carry out tasks on behalf of a client, and act as controllers or managers for other beans.

  • Entity beans — represent persistent objects or business concepts that exist beyond a specific application's lifetime; they are typically stored in a relational database. Entity beans can be developed using bean-managed persistence, which is implemented by the developer, or container-managed persistence, implemented by the container.

  • Message-driven beans — listen asynchronously for Java Message Service (JMS) messages from any client or component and are used for loosely coupled, typically batch-type, processing.

Enterprise JavaBeans are never accessed directly by clients. Instead, the container generates EJB proxy objects that implement the required home and component interfaces; these are used by a client for communication with a bean. The proxy objects then call upon the bean to perform the requested task. This mechanism allows the container to coordinate and manage beans however and wherever it sees fit; the client remains unaware of any internal details.


Next