Java - EJB: Enterprise Java Bean (enterprise beans)

Java Conceptuel Diagram

About

Enterprise beans are server-side J2EE components and run on the J2EE server in their EJB container which manages their execution. (Enterprise JavaBeans component model)

They handle the business logic of a J2EE application such as a web application. They contains the Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance.

An enterprise bean is a body of code with fields and methods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the J2EE server.

An enterprise bean:

  • receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage.
  • retrieves data from storage, processes it (if necessary), and sends it back to the client program.

J2ee Architecture

in Enterprise JavaBeans terminology the installation process is called deployment.

Advantages

  • Software Design - Scalability (Scale Up|Out). To accommodate a growing number of users, you can distribute an application’s components across multiple machines. Not only can the enterprise beans of an application run on different machines, but also their location will remain transparent to the clients.
  • Data - Transaction (Trans(versal?) actions) Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects.
  • Multiple presentation layers. The application will have a variety of clients. With only a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.

Type of Enterprise Beans

There are three kinds of enterprise beans:

  • Session: Performs a task for a client; optionally, may implement a web service
  • Message-driven: Acts as a listener for a particular messaging type, such as the JavaMessage Service API
  • Entity

Entity

In contrast with a session bean, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved.

One of the benefits of entity beans is that you do not have to write any SQL code or use the JDBC API directly to perform database access operations. With container-managed persistence, database access operations are handled by the the EJB container, and your enterprise bean implementation contains no JDBC code or SQL commands. However, if you override the default container-managed persistence for any reason, you will need to use the JDBC API.

Message-driven

A message-driven bean combines features of a session bean and a Java Message Service (“JMS”) message listener, allowing a business component to receive JMS messages asynchronously.

A message-driven bean is an enterprise bean that allows Java EE applications to process messages asynchronously.

This type of bean normally acts as a JMS message listener, which is similar to an event listener but receives JMS messages instead of events.

The messages can be sent by any Java EE component (an application client, another enterprise bean, or a web component) or by a JMS application or system that does not use Java EE technology.

Message-driven beans can process JMS messages or other kinds of messages.

The most visible difference between message-driven beans and session beans is that clients do not access message-driven beans through interfaces.

Message-driven beans do not have interfaces or no-interface views that define client access.

Unlike a session bean, a message-driven bean has only a bean class.

Naming Conventions

Item Syntax Example
Enterprise bean name nameBean AccountBean
Enterprise bean class nameBean AccountBean
Business interface name Account

EJBs and Other Application Components

Ejbenvironment

Documentation / Reference





Discover More
Data System Architecture
Data persistence

Persistence refers to the ability to store code objects on the disk. In an enterprise application, data is typically stored and persisted in the data tier, in a relational database. is the ability to...
Card Puncher Data Processing
Design Pattern - Dependency Injection

Dependency injection is: a dependency resolution mechanism where components (object, bean, client) are given their (type) dependencies (service, ..) (Dependencies are injected) and therefore are...
Eclipse Project Build Path
J2EE - EJB Remote Client with Eclipse OEPE on Weblogic (Outside the container)

How to create an EJB Remote Client with Eclipse OEPE on Weblogic ? To understand how an EJB is called through lookup, you must first read this article: . In this example, I create a simple EJB with a...
Java Conceptuel Diagram
J2EE - Session Bean

A session bean encapsulates business logic that can be invoked programmatically by a client over local, remote, or web service client views. To access an application that is deployed on the server, the...
Card Puncher Data Processing
JPA - Entity (Managed Classes)

xmlparserv2.jar Introduction to EclipseLink JPA (ELUG) for more information on the annotation.
Card Puncher Data Processing
JPA - Specification

The Java Persistence API (JPA) provides a mechanism for managing persistence,. object-relational mapping and functions for the EJB 3.0 and later specifications. See 317JSR 317: Java Persistence 2.0...
Java Conceptuel Diagram
Java - ( JDK | J2EE | J2SE )

SDK in Java core APIs for writing J2EE components, core development tools, and the Java virtual machine JDBC API 2.0 The Java 2 Platform, Standard Edition (J2SE) SDK is required to run...
Java Conceptuel Diagram
Java - Annotations

Since Java version 1.5. An annotation is an element of the java programming language (modifier or Metadata tag) that can be associated with: Java classes, interfaces, constructors, methods,...
Java Conceptuel Diagram
Java - Application

An application in shipped in an archive format with a main class that contains a main method that starts the application. instancejava/lang/Runtimeclass RuntimeOperating System environment ...
J2ee Server
Java - Application Server

application server in Java A J2EE Server is application server on the J2EE platform. It contains the web-tier and the business tier where the components are placed in logical container. Tier Components...



Share this page:
Follow us:
Task Runner