Enterprise JavaBeans (EJB) is a server-side distributed component model for the Java platform. EJB is a different technology from JavaBeans. Building distributed enterprise applications is difficult and introduces new challenges not present in many client-side applications. Developers need to support transactions, resource pooling, security, threading, persistence, remote access, and lifecycle issues. This results in system programming at the expense of business logic. With EJB, developers can focus on the business logic of applications without having to become specialists in system programming.
There are four parts to an EJB component:
home interface - how the component is found or created
remote interface - how the component is called
deployment descriptor - how the component is controlled
EJB class - business logic to execute
An EJB server provides the "plumbing" required to make an EJB component work, including:
authentication and authorization
concurrent service for multiple clients
clustering and high availability
There are currently two lifecycle models defined by EJB:
session EJB, based on a client session which can be either
entity EJB, based on a persistent data store, which can have either
bean managed state
server managed state
Work is also underway to define a message driven EJB model for use in message-based application architectures. An example of how EJB would be used in a web-centric architecture is shown in Figure 20-3. A user would access an application is this environment through a standard web browser. The web browser might contain either plain HTML, or an applet built with JavaBeans. The web browser would communicate with a web server using the HTTP protocol. The web server would use either Java Server Pages (JSP) or Java servlets to dynamically generate HTML for the browser and then communicate with an EJB on the application server via RMI/IIOP. The EJB would then execute the business logic of the application, fetching or storing data in a back-end DBMS via JDBC.