Types of EJB
By: aathishankaran in EJB Tutorials on 2007-02-20
There are three types of Enterprise Java Beans namely:
- Session Beans
- Entity Beans
- Message driven beans
- Session Beans
Session Beans are the most commonly used type of EJBs. They are lightweight and are designed to provide business logic to the client application. Session Beans can be of two types: stateless and stateful. Stateless session beans are used when the client doesn't need to maintain any state information between requests, while stateful session beans are used when the client needs to maintain state information between requests.
Session beans are divided into two types:
a) Stateless Session Bean: Stateless Session Bean is intended to be simple and "light weight" components. The client, thereby making the server highly scalable, if required, maintains any state. Since no state is maintained in this bean type, stateless session beans are not tied to any specific client, hence any available instance of a stateless session bean can be used to service a client.
b) State full Session Bean: State full Session Bean provides easy and transparent state management on the server side. Because state is maintained in this bean type, the application server manages client/bean pairs. State full session beans can access persistent resources on behalf of the client, but unlike entity beans, they do not actually represent the data. - Entity Beans:
Entity Beans represent persistent data and are used to interact with the database. They are responsible for storing and retrieving data from the database. There are two types of Entity Beans: Container Managed Persistence (CMP) and Bean Managed Persistence (BMP). In CMP, the container is responsible for all database interactions, while in BMP, the developer has to write the code to interact with the database. - Message-Driven Beans:
Message-Driven Beans (MDBs) are used for asynchronous communication between distributed components. They are used to listen to messages from a message queue or a topic and execute the required logic. MDBs are often used in distributed systems, where different components need to communicate with each other asynchronously.
Each type of EJB has its own specific purpose and benefits, and can be used based on the requirements of the application.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in EJB ) |
Latest Articles (in EJB) |
Comments