Project

General

Profile

Sample-jta-spring » History » Version 7

Henning Blohm, 02.05.2014 09:49

1 3 Henning Blohm
h1. Using a Spring configured full-blown transaction manager across modules in Z2
2 1 Henning Blohm
3 7 Henning Blohm
As does [[Sample-jta-plain]], so does this sample demonstrate how to use Z2 with the Atomikos transaction manager. In this case however, we choose to use the Spring framework to configure the transaction manager and enable re-use using Z2's support for modular Spring applications (see also [[How to Spring]]).
4 3 Henning Blohm
5
The Wiki page [[How_to_TransactionManager]] explains the general principles behind transaction handling in Z2.
6
7
This sample is stored in "z2-samples.jta-spring":http://redmine.z2-environment.net/projects/z2-samples/repository/z2-samples-jta-spring. It implements exactly the same scenario as [[Sample-spring-hibernate]] with the exception of not using the built-in JTA implementation.
8
9
h2. Prerequisites
10
11
You need to run Java DB as network server on localhost. This is explained next.
12
13
The application will create a database "z2-samples"
14
15
{{include(How to run Java db)}}
16
17
h2. Running the sample
18
19
This sample is run as explained in [[How to run a sample]]. The 5 minutes version:
20
21
<pre><code class="ruby">
22
mkdir install
23
cd install 
24
git clone -b master http://git.z2-environment.net/z2-base.core
25
git clone -b master http://git.z2-environment.net/z2-samples.jta-spring
26
27
# on Linux / Mac OS:
28
cd z2-base.core/run/bin
29
./gui.sh
30
31
# on Windows:
32
cd z2-base.core\run\bin
33
gui.bat
34
</code></pre>
35
36
h2. Verifying
37
38 4 Henning Blohm
When everything is up, go to http://localhost:8080/jta-spring. You see something like this: 
39 3 Henning Blohm
40 5 Henning Blohm
!jta-spring-thingies.png!
41 3 Henning Blohm
42
And indeed, it's the same database we use elsewhere.
43
44
h2. Now to the point...
45
46 6 Henning Blohm
This sample illustrates how to use a third-party transaction manager, the Atomikos implementation in this case, in a modular application as indicated in  [[How_to_TransactionManager]]. This in conjunction with Spring resulting in a full-blown, highly adaptable and completely modular environment, scalable in deployment and development.