Java Reference
In-Depth Information
Now that you have had a glimpse of how POJO s and lightweight frameworks such
as Spring and JDO make development easier and faster, let's take a step back and
look at how you would decide whether and how to use them. If we blindly used
POJO s and lightweight frameworks, we would be repeating the mistake the enter-
prise Java community made with EJB s. Every technology has both strengths and
weaknesses, and it's important to know how to choose the most appropriate one
for a given situation.
This topic is about implementing enterprise applications using design patterns
and lightweight frameworks. To enable you to use them effectively in your applica-
tion, it provides a decision-making framework that consists of five key questions
that must be answered when designing an application or implementing the busi-
ness logic for an individual use case. By consciously addressing each of these
design issues and understanding the consequences of your decisions, you will
vastly improve the quality of your application.
In this chapter you will get an overview of those five design decisions, which
are described in detail in the rest of this topic. I briefly describe each design deci-
sion's options as well as their respective benefits and drawbacks. I also introduce
the example application that is used throughout this topic and provide an over-
view of how to make decisions about its architecture and design.
2.1 Business logic and database access decisions
As you saw in chapter 1, there are two quite different ways to design an enterprise
Java application. One option is to use the classic EJB 2 approach, which I will refer
to as the heavyweight approach. When using the heavyweight approach, you use
session beans and message-driven beans to implement the business logic. You use
either DAO s or entity beans to access the business logic.
The other option is to use POJO s and lightweight frameworks, which I'll refer to
as the POJO approach. When using the POJO approach, your business logic consists
entirely of POJO s. You use a persistence framework (a.k.a., object/relational map-
ping framework) such as Hibernate or JDO to access the database, and you use Spring
AOP to provide enterprise services such as transaction management and security.
EJB 3 somewhat blurs the distinction between the two approaches because it
has embraced POJO s and some lightweight concepts. For example, entity beans
are POJO s that can be run both inside and outside the EJB container. However,
while session beans and message-driven beans are POJO s they also have heavy-
weight behavior since they can only run inside the EJB container. So, as you can
see, EJB 3 has both heavyweight and POJO characteristics. EJB 3 entity beans are
 
 
 
 
 
Search WWH ::




Custom Search