Saturday, November 14, 2009

EJB3 – The much improved easy-to-use server-side component model

Earlier EJB versions have been criticized for their heavy-weight components model, but with EJB3 drastic improvements have been made to offer best possible server-side component available in the industry.

The primary goal of EJB3 is to reduce complexity EJB development model and provide ease-of-use and faster development approach to server-side components.

EJB3 has edge over other competing technologies with respect to server-side component model and I have highlighted some of the points below:
1. Annotations – The powerful feature of J2SE 1.5 contributes to the ease of development of EJB components. Using annotations, its “piece-of-cake” to convert a POJO to an Enterprise Bean.

2. Interceptors & Dependency Injection (DI) – DI provides optimization by resource injection during compile-time and frameworks like Spring have been using it for a long time. Utilizing the latest features of Core Java (J2SE 1.5 onwards), DI contributes in optimizing EJB3 development using Interceptors.
Developers can concentrate on business logic only and even log messages, security, etc. can be handled by Interceptors, which can be applied at method level or component level.

3. Elimination of Extra Classes – With EJB3, there is no need to provide Home Interface for Session Beans. Also, required interfaces for persistence entities have been eliminated as well.

4. Replacement of Entity Beans – Heavyweight Entity beans have been replaced by lightweight JPA Entities (POJO based) and it is a major shift in the way persistence has been handled so far. JPA takes the best of all worlds by providing best features of ORM tools (Hibernate, TopLink, IBATIS) , EJB2.1 CMP persistence model and JDOs.

5. Optional Callback Methods – Container Callback methods are optional and developers are no longer need to provide empty methods (general practice earlier) for these methods.

6. POJO Model – EJB3 has finally accepted plain Java objects for local/remote & enterprise bean classes and there is no need to implement any interface or extend any class. Annotations simplifies this process and bean type/client type are indicated by using annotations.

Though industry has already started using other persistence models (specially heavily relying on ORM tools) & POJO based frameworks for server-side component models, EJB3 has come up with new improved and standardized approach and it might be the revival of it.

Best of Luck to EJB3 model!!