beautypg.com

Configuring ​​tmftransactionmanager, Declarative transaction management, Annotations – HP Integrity NonStop J-Series User Manual

Page 36

background image

database properties specified in the applicationContext.xml file with the values specified
in the jdbc.properties file during runtime.

Modify the applicationContext.xml file for wiring the jdbc.properties file as shown
below:

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


classpath:jdbc.properties



NOTE:

For information on the complete configuration snippet of the applicationContext.xml

file and the jdbc.properties file for JDBC Type 2 driver, see

“Sample JDBC Configuration for

Spring” (page 334)

.

Configuring TmfTransactionManager

Spring framework provides the following ways for configuring the TmfTransactionManager:

Declarative Transaction Management

: In this case, the transaction action is defined in an XML

configuration file for each method (or class).

Programmatic Transaction Management

: In this case, the transaction action is hardcoded in

the code. This is similar to the JDBC transaction.

Consider a simple Plain Old Java Object (POJO) having a simple service. Let us see how to
configure the TmfTransactionManager in various ways to execute the POJO service in a TMF
transaction on a Nonstop system.

The POJO class is

public class SimpleService {

public void addRecord(){
//code to insert a record into a database
}
}

The bean definition for the Transaction Manager is as shown:

class="com.hp.nonstop.spring.tmf.TmfTransactionManager">

Assume that the file containing this definition is txbean.xml.

Declarative Transaction Management

Using declarative transaction management, you can configure the TmfTransactionManager
in the following ways:

Annotations

Aspect Oriented Programming (AOP)

Annotations

To configure the TmfTransactionManager using the annotation method, you must configure
the application's XML file. An example of the XML configuration is as shown:



36

Spring Framework

This manual is related to the following products: