Java Reference
In-Depth Information
EJB
returns a
TransferResult
, which is a
DTO
that contains the
AccountDTO
s and
their recent transactions. It is used by the presentation tier to display a web page to
the customer.
The
DAO
s, which are implemented using
JDBC
, provide methods for accessing
the database. This application could also use entity beans instead of
DAO
s to
access the database. That is, after all, the role of entity beans within the
J2EE
architecture. However, for reasons I describe later,
EJB 2
entity beans have several
drawbacks and limitations. As a result, many
J2EE
applications use
DAO
s instead
of
EJB 2
entity beans.
The class design and their relationships are simple. I haven't shown the
XML
deployment descriptors, which are used to configure the
EJB
, but
Transfer-
Service
is ready to be invoked remotely and to participate in distributed transac-
tions. But despite its apparent simplicity (and sometimes because of it), several
serious problems lurk within.
1.1.3
The problems with EJBs
Like many other Java developers, I enthusiastically adopted
EJB
s and spent several
years writing applications whose design was similar to the one you just saw. I was so
excited about using the new standard that I thought nothing of abandoning the
object-oriented design skills I'd spent the previous decade learning. I was more
than happy to write lots of code and
XML
configuration files just to do the sim-
plest things. I found ways to pass the time while my code deployed. After all, isn't
enterprise application development meant to be challenging?
It is certainly true that some aspects of developing enterprise applications are
challenging, such as complex and changing requirements and the need to scale and
have high throughput and availability. However, while
EJB
solves some problems
with developing enterprise applications, it does not live up to one of its key goals:
making it easy to write applications. Ironically, in order to be a competent
EJB
devel-
oper you need to know how to solve problems that are caused by
EJB
. An excellent
book that tackles the shortcomings of
EJB
is
Bitter
EJB
by Bruce Tate [Tate 2003].
Other books address the complexity of building effective
EJB
applications, such as
Core J2EE Patterns
[Alur 2003] and
EJB Design Patterns
[Marinescu 2002], which con-
tains patterns to help make sense of
EJB
and solutions to problems rather than pat-
terns for improving the design of software.
Although these topics help developers grapple with
EJB
and learn how to use it
effectively, they don't directly address the two fundamental problems with
EJB
s.
The first is that
EJB
s encourage developers to write procedural-style applications.
The second problem is that the cumbersome nature of the development process
Search WWH ::
Custom Search