Java Reference
In-Depth Information
<!-- other methods use the default transaction propagation attribute REQUIRES
-->
<tx:method name="underwrite*"/>
<tx:method name="update*" propagation=”REQUIRES_NEW”/>
</tx:attributes>
</tx:advice>
<!-- DataSource -->
<!-- Platform Transaction Manager, in this straight jdbd -->
<bean id="txManager" class="org.springframework.jdbc
å
.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<aop:config>
<aop:pointcut id="uwrServiceMethods" expression="execution(*
å
com.apress.einsure.business.*.Underwriting*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="uwrServiceMethods"/>
</aop:config>
<!-- other beans -->
</beans>
The transaction attributes have been set with the AOP advice. All methods starting
with
list
are read-only and do not participate in transactions. Methods starting with
underwrite
are associated with a default transactional propagation attribute of
REQUIRED
.
This is similar to the EJB transaction setting. An invocation of the
underwriteNewpolicy
method on
UnderwritingApplicationService
will result in this method, either starting a
new transaction or joining an existing transaction. Similarly, any update method will run
in a new transaction scope.
Unlike in EJBs, the Spring Framework supports a declarative rollback configuration
as well. In general, if a
Runtime
exception (or its subclass) is thrown from the POJO appli-
cation service method, Spring will mark that transaction for rollback. It is possible to
specify the exceptions that will result in rollback. You can also configure the exceptions
that will not cause a rollback, as shown in Listing 6-33.
