KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > db > jtx > DbJtxSession


1 // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
2

3 package jodd.db.jtx;
4
5 import jodd.db.DbSession;
6 import jodd.db.DbTransactionMode;
7 import jodd.db.connection.ConnectionProvider;
8 import jodd.jtx.JtxResource;
9 import jodd.jtx.JtxTransactionMode;
10
11 /**
12  * {@link jodd.db.DbSession} adapter for {@link jodd.jtx.JtxResource} interface.
13  */

14 public class DbJtxSession extends DbSession implements JtxResource {
15
16     public DbJtxSession(ConnectionProvider connectionProvider) {
17         super(connectionProvider);
18     }
19
20     /**
21      * Invokes {@link #closeSession()}.
22      * @see jodd.jtx.JtxResource#closeResource()
23      */

24     public void closeResource() {
25         super.closeSession();
26     }
27
28     protected JtxTransactionMode jtxMode;
29
30     /**
31      * Returns current transaction mode.
32      * @see jodd.jtx.JtxResource#getTransactionMode()
33      */

34     public JtxTransactionMode getTransactionMode() {
35         return jtxMode;
36     }
37
38     /**
39      * Indicate whether a transaction is in progress.
40      * @see jodd.jtx.JtxResource#isTransactionActive()
41      */

42     public boolean isTransactionActive() {
43         return super.isTransactionActive();
44     }
45
46     /**
47      * Starts a transaction.
48      */

49     public void beginTransaction(JtxTransactionMode mode) {
50         this.jtxMode = mode;
51         super.beginTransaction(new DbTransactionMode(mode));
52     }
53
54 }
Popular Tags