EJBs are server side components of an enterprise application and it runs in EJB container of an application server. EJB contains business logic for the enterprise and distributed applications which are to developed to use at large scale. Ejbs are reusable and portable components which can be used in any new application and can be deployed on any application server containing ejb container. With the help of ejb the client user can focus on its own part rather than thinking about business logic implemented behind the scene in the ejb components.
Types of EJB:
There are three types of Enterprise Java Beans:
1. Session Beans
a) Stateless Session Bean (Business Objects that don't have state)
A single bean object can be accessed by only one client at a time i.e. no two clients can access the single instance concurrently
b) Stateful Session Bean (Business Objects having state)
A bean instance can be accessed by only one client at a time because it keeps state information of the calling client throughout session.
2. Entity Beans
Represents a business entity object
3. Message driven beans
Invoked upon receiving asynchronous message.
EJB 3.0: EJB 3 provides more enhanced features and simple architecture than earlier version EJB 2. Some of the new features in EJB 3.0 are as follows:
1. Metadata Annotations
2. Encapsulation of environmental dependencies
3. More simplified EJB Specification
4. Dependency Injection
5. Simplification of Entity Persistence
6. Callback interfaces