Javatpoint Logo
Javatpoint Logo

EJB Container

EJB is a server-side software element that summarizes the business logic of an application. Enterprise Java Beans web repository yields a runtime domain for web-related software elements including computer reliability, Java Servlet Lifecycle (JSL) management, transaction procedure, and other web services.

What is an EJB container?

EJB container is a server-side component that comprises the business logic. It offers local and remote access to the enterprise beans. In other words, we can say that it provides a runtime environment for EJB applications within the application server. A single EJB container can have one or more EJB modules. It acts as an intermediate action between business logic and enterprise application. The following figure depicts the structure of the EJB container.

EJB Container

The typical behavior envisioned by the Java EE specification is that a developer writes an Enterprise JavaBean, a simple component, and the EJB container adds the necessary infrastructure for communications, transactions, and data access. It turns the business logic into something that executes.

In addition, the EJB container provides lifecycle management for the component to ensure that its creation, usage, and destruction are both efficient and in accord with the specification.

When the EJB container is started, it has, at its highest level, the EJBContainerImpl class as its controller. It is a subclass of the generic ContainerImpl class. EJBContainerImpl implements the EJBContainer service interface and has listeners for changes to the deployed application modules and other parts of the environment.

Let's see the inheritance dependencies, methods, and interfaces that define the EJB container.

EJB Container

But if we look at the WsComponent interface, we can see some key methods that explain how the components, and therefore the container, are controlled by the WAS runtime environment. The ContainerImpl class is a subclass of the ComponentImpl class, so it can be treated like any other component by the loadComponents calls of the outer container that initializes it. It is how the base server starts, controls, and interacts with the EJB container.

It is responsible for creating the enterprise bean, binding the enterprise bean to the naming service so that other application components can access the enterprise bean, ensuring only authorized clients have access to the enterprise bean's methods, saving the bean's state to persistent storage, caching the state of the bean, and activating or passivating the bean when necessary.

The EJB Container Implementation Class

The EJBContainerImpl class is a complex class with many dependencies, as shown in the following figure. Some of the dependencies are structural and inheritance-related, and some are dynamic and collaborative in nature.

EJB Container

Using reflection, we can see the interfaces that the EJBContainerImpl class uses.

What does an EJB container do?

EJB container performs the following tasks:

  • Instantiate beans on demand
  • Manages a pool of bean instances
  • Manage Transactions
  • Loads/ saves bean data from/to a database
  • Handles Security
  • Provides other System Services
EJB Container

EJB Container Services

EJB Container provides the following valuable services for enterprise application development.

  • Transaction support (start, rollback, and commit)
  • Security Model
  • Persistence Support
  • Timing Services and Job Scheduling
  • Messaging
  • Remote Access
  • Distribution
  • Web-services
  • Component Pooling
  • Component Life-cycle
  • Interceptors
  • Asynchronous Interactions
  • Thread-safety and Concurrency Control

Next Topic#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA