Simplifying EJB Development with EJB3.0
使用EJB3.O简化EJB开发 原著：Debu Panda
Enterprise JavaBeans (EJB) was introduced for building distributed components. When it arrived it came with a promise to solve all issues and complexities of CORBA. EJB being the heart of J2EE went through several major revisions and got fattened with many features. Early on, most of the developers fell in love with EJB and used EJB in their application even it did not make any sense. “Blame it on EJB” has been the attitude for many developers when their projects did not scale well and they used EJB.
Development of EJB was never easier and it became more complex with every release of EJB specification. EJB has been compared with an elephant due to its complexity and heavy weight nature. Many developers feel EJB is like an extra layer of sugar syrup on a doughnut. In an age where low carb and Atkins diet is craze, the EJB expert committee has no option but to produce a low carb incarnation of EJB thus simplifying the development of EJB. EJB 3.0 expert committee released a sample picture of the lightweight model during JavaOne 2004 when it announced release of first public draft of EJB 3.0 Specification.
开发EJB从来没有变得简单甚至在早期的EJB版本规范中变得更加复杂。EJB由于其的复杂性和重量级特性而被比作一只大象。学多开发人员感觉EJB象一个油炸圈饼上多余的一层甜糖浆。在现在low carb和Atkins diet大行其道的今天，EJB专家委员会也没有选择余地的发布了体现low carb的EJB规范来简化EJB的开发。EJB3.0专家委员会在2004Javaone大会上发布了称之为EJB3.0第一个公开规范的轻量级模型的范例图。
At the first glimpse the new model for EJB looks pretty and in this article we will discuss how EJB 3.0 is trying to dress up in a smaller size pretty outfit to make it appealing for developers. In a follow up article we will discuss how EJB 3.0 is simplifying the persistence model.
Cleaning up the Dirty Laundry整理缺陷
Let us look at the complexities in the current EJB model before we dive down discussing the details what EJB 3.0 is bringing on to the table.
• The current EJB model requires creation of several component interfaces and implementation of several unnecessary callback methods.
• The component interfaces require implementation of EJBObject or EJBLocalObject and handling of many unnecessary exceptions is required.
• The EJB deployment descriptor is complex and error prone.
• The container managed persistence being based on the EJB model is again overly complex to develop and manage. There are several basic features missing such as a standard way to define a primary key using database sequence and EJBQL is very limited.
• EJB components do not look like its Object Oriented as it has restrictions for using inheritance and polymorphisms.
• One major drawback of EJBs is that you cannot test EJB modules outside an EJB container and debugging an EJB inside the container is a nightmare for developers.
• If you used EJB you know the complexities of looking up and invocation of EJB. It appears that you have to know minute details of JNDI to just use an EJB in your application.