Session Beans and their types.
Hello Friends, In this blog post(Session Beans and their types) we are going to discuss the session beans and their types in detail. Session beans are mainly divided into two types: stateful and another is stateless session beans.
Session beans(Session Beans and their types) contain some specific business-processing-related logic. It is a Java object that encapsulates the necessary code for performing a set of operations corresponding to one more business process.
The business processes are business logic, business rules, or workflow. A session bean is a reusable piece of software. For example, a session bean update salary could be used to update the salary of one or all employees.|(Session Beans and their types)
The term session stems from the fact that the life of a session bean is limited to the time for which a client uses the services of a session bean.
When the client code invokes the services of a session bean the application server creates an instance of the session beans.
The session beans then service the client as long as necessary.
When the client completes the job and disconnects, the application server destroys the instance of the session bean.
An instance of the session bean is unique in that no two or more clients can share a single session bean.
This is essential for ensuring transaction management.
If two or more clients use the service of the same instance of a session bean, there would be confusion.
Because they might accidentally access the same data.
To avoid this, session beans can be made thread-safe, so that two or more session beans can share codes, but maintain separate copies of data.
However, this is an implementation issue that needs to be decided by the application server vendor.
From a common developer’s perspective, a session bean is never shared among users.
A client never explicitly creates an instance of or destroys a session bean, It is always done by the EJB container running inside the application server.
It ensures the optimum utilization of bean resources.
Also, this frees the client from issues such as stack management, etc. And provides an interface.
The application server does the bean management.
There are two types of session beans, stateful session beans, and stateless session beans.
Session Beans and their types
Stateful session beans:
A session beans corresponds to a business process.
However, a business process may be completed in just one stroke, or it might need more than one interaction between the client and the server.
The concept of the transaction is more relevant for the latte.
In this case, when the clients and servers interact more than once during the entire life cycle of this interaction, the state of the application must be preserved.
If all the steps during these sets of interactions are completed successfully, the operation as a whole can be considered to be successful.
for handling such situations, or more correctly transactions, stateful session beans are very important.
A typical situation that needs multiple interactions between the client and the server is a shopping cart in an e-commerce application.
Initially, the application might present a shopping cart to the user. Then the user might add items to it, remove items from it, or change some of the items.
This interaction goes on for quite some time. In such a scenario, a stateful session is very useful.
Stateless session beans:
An interaction between a web browser and a web server consists of a request-response pair.
It means that the browser sends a request for an HTML document, and the server finds the document and sends it back as a response to the browser.
In such a situation where the client and the server interact in a request-response mode and then forget about it.
There is no necessity for maintaining the state of the application. Stateless session beans are candidates for such business processes.
For example, in an e-commerce application, the client might enter the credit card details, such as the issuing company, number, expiry date, and the customer’s name.
It might request stateless session beans to verify these credit card details.
These stateless session beans might perform the verification and send a success or a failure…
… message back to the client, depending on whether the credit card is valid- Session Beans and their types
require mo more interactions between the client and the server. Such business scenarios are useful for the stateless session beans| (Session Beans and their types)
You can also go through a few more amazing blog post links below related to core Java:
Keywords In Java In Hindi…
OOPS, Concepts In Java In Hindi…
Data Abstraction In Hindi…
Encapsulation In Hindi…
Wrapper Class In Java In Hindi…
Access Specifiers In Java…
JDBC Driver In Java In Hindi…
Types of JDBC Driver In Java…
Session Beans and their types…
EJB Features: Enterprise Java Beans Features…
Symptoms of an overloaded server…
EJB In Java In Hindi…
Java Beans In Hindi…
What is ODBC in Java in Hindi…
What is JDBC In Hindi…
What are JSP and its advantages…
Advantages and Disadvantages of Servlet…
What is Servlet and why it is used…
Static Keyword In Java In Hindi…
In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.
Hope! you would have enjoyed this post Session Beans and their types.
Please feel free to give your important feedback in the comment section below.
Have a great time!