Java Reference
In-Depth Information
the UserTransaction.commit method. Likewise, if the transaction fails, the
UserTransaction.rollback method will be called.
Application Server Transaction
JTATransactionManager can work with application server transaction support. However,
application servers differ significantly with regard to their transaction management
implementation. They also provide varying degrees of transaction optimizations. To
leverage them, Spring comes with a few application-server specific transaction man-
agers: WeblogicJtaTransactionManager (BEA WebLogic), WebsphereUowTransactionManager
(IBM WebSphere), and OC4JtaTransactionManager (Oracle Application Server).
Declarative Transaction
Declarative transaction management support is immensely useful for applications
because it has the least impact on source code. It is nonintrusive and allows transaction
to be applied to a component transparently. The Spring Framework supports declarative
transaction management through its AOP module. In the next few sections, I will show
how Spring declarative transactions can be applied to the application service classes dis-
cussed in Chapter 4.
The first step to using Spring declarative transaction is to create an advice. In the
case of transaction management, the transaction manager applies an advice, as shown in
Listing 6-30.
Listing 6-30. transaction-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=" http://www.springframework.org/schema/aop"
xmlns:tx=" http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!-- this is the service object on which the transaction has to be applied -->
<bean name="uwrAppService"
 
Search WWH ::




Custom Search