Java Reference
In-Depth Information
object model there are classes that do not fall into one of these three categories. As
a result, many classes are unable to use the services provided by the EJB 3 container.
Also, the June 2005 public draft of the specification still had only limited support
for collection classes. In addition, there is no guarantee that the EJB 3 containers
will provide fast and painless deployment of EJB s. As a result, EJB 3 still appears to
be inferior to the lightweight technologies such as JDO , Hibernate, and Spring that
I describe later in this chapter.
Despite its limitations, it is extremely likely that EJB 3 will be widely used for the
simple reason that it is part of the J2EE standard. It is also important to remember
that EJB is an appropriate implementation technology for two types of applications:
Applications that use distributed transactions initiated by remote clients
Applications that are heavily message-oriented and need message-driven
beans
But for many other applications superior alternatives exist that are considerably
easier to use. The remainder of this topic focuses on those alternatives: POJO s and
lightweight technologies such as Spring, Hibernate, and JDO .
1.2 Developing with POJOs
Long before the EJB 3 specification was written, some developers disillusioned
with EJB started to look for alternative frameworks. POJOs are an especially com-
pelling alternative to EJB s. A POJO is simply a Java object that does not implement
any special interfaces such as those defined by the EJB framework. The name was
coined by Fowler, Rebbecca Parsons, and Josh MacKenzie [Fowler POJO ] to give
regular Java objects an exciting-sounding name. Later in this section you will see
how this simple idea has some surprisingly important benefits.
However, POJO s by themselves are insufficient. In an enterprise application you
need services such as transaction management, security, and persistence, which
were previously provided by the EJB container. The solution is to use the increas-
ingly popular so-called “lightweight” frameworks that replace some “heavyweight”
parts of the J2EE stack. They do not completely replace the J2EE stack but can be
used in combination with some parts of it to provide important enterprise services.
The four lightweight frameworks that I describe in this topic are Hibernate, JDO ,
i BATIS , and Spring. Except for JDO , which is a specification, they are open source
projects, which have helped drive the adoption of POJO s and lightweight frameworks
by the community. Hibernate and JDO are persistence frameworks, which map
POJO s to a relational database. They are layered on top of JDBC and significantly
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search