What is EJB 3.0?

This very useful JEE 5.0 and EJB 3.0 Tutorial. You will learn about EJB 3.0 and its benefits.

What is EJB 3.0?

This very useful JEE 5.0 and EJB 3.0 Tutorial. You will learn about EJB 3.0 and its benefits.

What is EJB 3.0?

What is EJB 3.0


This lesson introduces you with EJB 3.0, which is being used extensively for developement of robust, scalable and secure applications.

What is EJB?

The Enterprise JavaBeans architecture or EJB for short is an architecture for the development and deployment of component-based robust, highly scalable business applications. These Applications are scalable, transactional, and multi-user secure. You can develop the application once and then deploy on any one of the JEE 5 complaint application server. There are many application servers are available both free and commercial. You can choose the server for development and deployment to suit your requirement and budget.

Benefits of EJB

EJB simplifies the development of small and large enterprise applications. The EJB container provides system-level services to enterprise beans, the bean developer can just concentrate on developing logic to solve business problems.

Types of EJB

  1. Session Bean
    Session is one of  the EJBs and it  represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.
    A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates. 
    Session Bean Types
    Session Beans are of two types, Stateful Session Bean and Stateless Session Bean. 
    Stateless Session Beans
    A stateless session bean does not maintain a conversational state for the client. When a client invokes the method of a stateless bean, the bean's instance variables may contain a state, but only for the duration of the invocation.
    Because stateless session beans can support multiple clients, they can offer better scalability for applications that require large numbers of clients. Typically, an application requires fewer stateless session beans than stateful session beans to support the same number of clients.

    Stateful Session Beans
    The state of an object consists of the values of its instance variables. In a stateful session bean, the instance variables represent the state of a unique client-bean session. Because the client interacts ("talks") with its bean, this state is often called the conversational state.
  2. Entity Bean
    Enity beans are persistence java objects, whose state can be saved into the database and later can it can be restored from Data store. Entity bean represents a row of the database table.
  3. Message Driven Bean
    Message Driven Bean is an enterprise bean that can be used by JEE applications to process the messages asynchronously. Message Driven Bean acts as message consumer and it receives JMS messages.

EJB 3.0 New Features

Following are the new features of EJB 3.0:

  1. Metadata Annotations
    EJB 3.0 extensively uses the metadata annotations to simplify the development of EJB 3.0 components. Now there is no need to write the deployment descriptor, but the deployment descriptor is still supported. Annotations can be overridden by deployment descriptor.
  2. Encapsulation of environmental dependencies
    EJB 3.0 now uses the annotations and dependency injection mechanism to encapsulation the environmental dependencies and JNDI access.
  3. More simplified EJB Specification
    EJB 3.0 is simplified Specification but still very powerful. Now there is no need to write home and component interfaces and implementing the javax.ejb.EnterpriseBean interface by EJB class. The EJB bean class is now pure java class, also know as POJO and the interface is know as POJI is simple Java interface. So, you can now developed your enterprise application very fast.
  4. Dependency Injection
    Now the API for lookup and usage of EJB environment and resource references has been simplified and dependency injection is used through metadata annotations.
  5. Simplification of Entity Persistence
    Persistence of the entity objects are now very simple through the introduction of Java Persistence API. A new API EntityManager API has been introduced is used create, find, remove and update entities. Now the domain objects supports inheritance and polymorphism.
  6. Callback interfaces 
    Elimination of the requirement for the implementation of callback interfaces.