Java Reference
In-Depth Information
model services that are called by the presentation tier. The interceptor begins a
transaction when a domain model service is invoked and commits the transaction
when it returns. The interceptor might also roll back a transaction if an exception
is thrown. Figure 8.6 shows how the various classes collaborate in a design that
uses this approach.
The sequence of events is as follows:
The web container invokes the connection filter.
1
The connection filter calls the persistence framework to open the connec-
tion.
2
The filter calls the servlet.
3
The servlet invokes the PlaceOrderService .
4
The TransactionInterceptor begins the transaction.
5
The PlaceOrderService is invoked and updates the PendingOrder .
6
The TransactionInterceptor commits the transaction.
7
The servlet forwards the request to the JSP page.
8
The JSP uses the domain objects such as the PendingOrder to generate the
response.
9
The filter calls the persistence framework to close the connection.
10
Persistence
Tier
Presentation Tier
Business Tier
:W e b
Container
doFilter()
: Transaction
Interceptor
: P l a c e O r d e r
Service
: Connection
Filter
:Persistence
Framework
:JSP
:Servlet
:PendingOrder
open()
service()
updateDeliveryInfo()
beginTxn ()
serviceMethod()
commitTxn()
<<forward>>
getDeliveryAddress()
close()
Figure 8.6
Managing transactions with an AOP interceptor around the domain model services
Search WWH ::




Custom Search