Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Ease of use- A EJB is a simple POJO plus annotation.
  2. Complete stack of solutions for EJB development which includes persistence, messaging, annotations, dependency injection.
  3. Broad vendor support- which includes the support from market players like IBM, Oracle and open source vendors like Apache Geronimo.
  4. Annotations can be used in place of deployment descriptors.
  5. Dependency Injection as against performing a JNDI lookup for the resources.
    We sill discuss each of these in upcoming sections and EJB applications.

Types of Beans

There are three different types of beans as was discussed earlier

  • Session Beans
    1. Stateless Session Bean
    2. Stateful Session Bean
  • Message Driven Bean
  • Entity Beans
    We will discuss each type of Bean one by one.

Stateless Session Bean

Stateless beans are used in the case when the process or action can be completed in one go. In this case object state will not be preserved in a series of linked invocation. Each invocation of bean will be unique in itself in a Stateless Session Bean. A stateless session bean in represented by @Stateless annotation.

Example of Simple Stateless Session Bean

Code Block
titleStatelessBean.java
borderStylesolid

@Stateless
public class StatelessBean implements StatelessBeanRemote
{
public void SimpleFunction()
{
System.out.println("This is a stateless session bean");
}
}

As can be seen in the code @Stateless defines a simple POJO as a Stateless Session bean.

The above gives a very highlevel idea of what is a stateless session bean and how is it implemented using EJB3 annotations.
While working with examples we will try to make you understand stateless session beans in-depth.