Java Reference
In-Depth Information
façade, the AOP interceptors intercept the calls to the POJO façade and authenti-
cate the caller and begin, commit, and roll back transactions.
The POJO façade approach simplifies development by enabling all of the busi-
ness logic to be developed and tested outside the application server, while provid-
ing many of the important benefits of EJB session beans such as declarative
transactions and security. As an added bonus, you have to write less code. You can
avoid writing many DTO classes because the POJO façade can return domain
objects to the presentation tier; you can also use dependency injection to wire the
application's components together instead of writing JNDI lookup code.
However, as you will see in chapter 7 there are some reasons not to use the
POJO façade. For example, a POJO façade cannot participate in a distributed
transaction initiated by a remote client.
2.3.3
Exposed Domain Model pattern
Another drawback of using a façade is that you must write extra code. Moreover,
as you will see in chapter 7, the code that enables persistent domain objects to be
returned to the presentation tier is especially prone to errors. There is the
increased risk of runtime errors caused by the presentation tier trying to access an
object that was not loaded by the business tier. If you are using JDO , Hibernate, or
EJB 3 , you can avoid this problem by exposing the domain model to the presenta-
tion tier and letting the business tier return the persistent domain objects back to
the presentation tier. As the presentation tier navigates relationships between
domain objects, the persistence framework will load the objects that it accesses, a
technique known as lazy loading . Figure 2.6 shows a design in which the presenta-
tion tier freely accesses the domain objects.
Web
Component
Web
Component
Presentation Tier
Business Tier
Spring AOP
AOP-Managed Transactions
AOP-Based Security
Business
Object
Business
Object
Figure 2.6
Using an exposed
domain model
Business
Object
 
 
Search WWH ::




Custom Search