|Home > Apache Geronimo v2.1 > Documentation > Developer's guide > Tutorials > EJB applications|
Enterprise JavaBeans(EJB) is a platform for developing reusable and portable java applications. In very simple terms we can say that EJB is a java code that runs in a runtime environment called EJB container.
EJB has three different types of components Session beans, Message Driven Beans and Entity bean. Session beans and Message Driven Beans are used for developing the Business logic and Entity beans are used for persistence.
EJB provides the following services transactions, persistence, State Management, Messaging, Security and many more. EJB can be considered as a framework because of the components and services they provide for Enterprise Application Development.
This document is organized in the following sections:
EJB2 was quite complex for developers. It involved lot of code- home interface, remote interface, local interface, Bean class and deployment descriptors. Also you need to write lot of bean class which are never called but where required by the bean class to implement interface. You need to implement life cycle callback method likes ejbCreate, ejbRemove, ejbActivate, ejbPassivate compulsorily even if those are not required. Also many object oriented features such as inheritance, polymorphisms were not supported by EJB2.
EJB3 as against to EJB2 has undergone a great change. The hard work and innovations from the community has simplified EJB development to a great extent. In EJB3, classes are nothing but a simple Plain Old Java Object(POJO) and interfaces are Plain Old Java Interfaces(POJI). EJB3 objects are plain java object which are given special powers with Annotations. A POJO plus Annotation is nothing but a EJB3 object. EJB3 is one of the best framework available for server side development due to the following reasons
There are three different types of beans as was discussed earlier
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
As can be seen in the code @Stateless defines a simple POJO as a Stateless Session bean.
The above gives a very high level 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.