You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

EJB- A brief Introuduction

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 persisitence.
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.

EJB2 Vs EJB3

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 lifecycle callback method likes ejbCreate, ejbRemove, ejbActivate, ejbPassivate compulsorily even if those are not required. Also many object oriented features such as inheritance, polymorphism were not supported by EJB2.

EJB3 as against to EJB2 has undergone a great change. The hardwork 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 objetcs 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 serverside development due to the following reaseons

  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.
  • No labels