Goseeko blog

What are the Types of Beans?

by Bhumika

In Java, there are three types of enterprise javaBeans

  • Session beans
  • Message driven beans
  • Entity beans

Session beans –

A session bean is a set of business logic that a client can access locally, remotely, or via a web service.

  1. Stateful  session – Values of an object’s instance variables influence its state. Additionally, The status of a single client/bean session is capture a stateful session bean’s instance variables. This stage is known as the conversational state because the client communicates (“talks”) with its bean.

Moreover, The state is kept constant for the duration of the client/bean session. Furthermore, The session expires and the state vanishes if the client removes the bean. However, the state’s ephemeral nature is not a concern because there is no need to keep the state after the client-bean dialogue has ended.

  1. Stateless  session – The communication of the client is not track a stateless session bean. When a client uses the methods of a stateless bean, the bean’s instance variables may have a state that is specific to that client, but only for the duration of the call. After the method has done, the client-specific state should not be maintained.

A web service can implemented by a stateless session bean, but not by a stateful session bean. An application often requires fewer stateless session beans to serve the same number of customers than stateful session beans to service the same number of clients.

Message  driven beans –

It has the same business logic as Session Bean, except it calling passing a message.

Entity  beans –

It summarizes the condition of the database that can save. It is frowned upon. JPA has now taken its position (Java Persistent API). Entity beans are categories into two categories:

  1. Bean Managed Persistence :

The programmer must create the code for database requests in a bean controlled persistence kind of entity bean. It continues to exist throughout several sessions and clients.

2. Container Managed Persistence :

Container controlled persistence is a database persistence enterprise bean. The container manages database calls in container-controlled persistence.

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

You may also like