Manual

Defining the Transactional Execution Point
To ensure that the transactional advice defined in the above step is executed at the appropriate
point in the program, you must define the transactional execution point. This is done using the
<aop:config/> definition in the applicationContext.xml file.
Define a pointcut that matches the execution of any operation defined in the Transactional Service
interface. Associate the pointcut with the advisor. The result indicates that at the execution of a
Transactional Service operation, the advice you have defined will be run.
<!-- ensure that the above transactional advice runs for any execution
of an operation defined by the Transactional service interface -->
<aop:config>
<aop:pointcut id="<transactional operation id>" expression="<execution expression>"/>
<aop:advisor advice-ref="<transactional advice id>" pointcut-ref="<transactional operation id>"/>
</aop:config>
For example:
To run the transactional advice for any execution of an operation defined in the MyService
interface, define the transactional execution point as:
<aop:config>
<aop:pointcut id="myServiceOperation" expression="execution(* x.y.service.MyService.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="myServiceOperation"/>
</aop:config>
In this case, the <aop:config/> definition ensures that the transactional advice defined by
the txAdvice bean actually executes at the appropriate points in the program. Define a pointcut
that matches the execution of any operation defined in the MyService interface
(myServiceOperation). Associate the pointcut with the txAdvice using an advisor. The
result indicates that at the execution of a myServiceOperation, the advice defined by txAdvice
will be run.
Defining the Transaction Datasource
This section describes the steps to define the datasource that will be used by the transaction. For
more information on datasource configuration, see the Configuring JDBC Driver for SQL/MX
Database.
Add the following lines in the applicationContext.xml file to create the datasource:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
</beans>
82 Configuring Spring Applications on NonStop Systems