Java Reference
In-Depth Information
increase developer productivity. i BATIS is also layered on top of JDBC , but it maps
POJO s to SQL statements and is a very convenient way to execute SQL statements.
The Spring framework has a wide range of features that make it easier to use than
EJB , including the equivalent of container-managed transactions for POJO s.
An important feature of these technologies is that they are nonintrusive.
Unlike EJB s, they provide transactions and persistence without requiring the
application classes to implement any special interfaces. Even when your applica-
tion's classes are transactional or persistent, they are still POJO s, which means that
you continue to experience the benefits of POJO s that I describe in this chapter.
Some excellent topics are available that describe these frameworks in depth:
Hibernate in Action [Bauer 2005], Spring in Action [Walls 2005], i BATIS in Action
[Begin, forthcoming], and Java Data Objects [Russell 2003]. You do not need to
read these topics to understand and benefit from this topic. But to apply what you
learn here you do need to read them to learn the details.
In this section I will provide an overview of how to use POJO s and lightweight
frameworks to redesign the money transfer service and make it easier to develop,
test, and maintain. This new design is object-oriented POJO -based instead of a
procedural EJB -based. It accesses the database using a persistence framework that
is layered on top of JDBC instead of using JDBC directly. The business logic is
encapsulated by a POJO façade instead of a session bean, and transactions are
managed by the Spring framework instead of the EJB container. The business
logic returns real business objects to the presentation tier instead of DTO s. The
application is assembled by passing a component's dependencies as setter or con-
structor arguments instead of the component using Java Naming and Directory
Interface ( JNDI) lookups. Because the design is object-oriented and uses these
lightweight technologies, it is much more developer-friendly than the EJB version
we saw earlier.
Table 1.1 summarizes the differences between the two designs.
Table 1.1
Comparing classic EJB and POJO approaches
Classic EJB approach
POJO approach
Organization
Procedural-style business logic
Object-oriented design
Implementation
EJB-based
POJOs
Database access
JDBC/SQL or Entity beans
Persistence framework
Returning data to the
presentation tier
DTOs
Business objects
 
 
 
Search WWH ::




Custom Search