KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > txn > AutoTxn


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: AutoTxn.java,v 1.27 2006/10/30 21:14:26 bostic Exp $
7  */

8
9 package com.sleepycat.je.txn;
10
11 import com.sleepycat.je.Database;
12 import com.sleepycat.je.DatabaseException;
13 import com.sleepycat.je.TransactionConfig;
14 import com.sleepycat.je.dbi.EnvironmentImpl;
15
16 /**
17  * An AutoTxn is one that's created by use of the AutoCommit property.
18  */

19 public class AutoTxn extends Txn {
20
21     public AutoTxn(EnvironmentImpl env, TransactionConfig config)
22         throws DatabaseException {
23
24         super(env, config);
25     }
26
27     /**
28      * AutoTxns abort or commit at the end of the operation
29      */

30     public void operationEnd(boolean operationOK)
31         throws DatabaseException {
32
33         if (operationOK) {
34             commit();
35         } else {
36             abort(false); // no sync required
37
}
38     }
39
40     /**
41      * AutoTxns abort or commit at the end of the operation
42      */

43     public void operationEnd()
44         throws DatabaseException {
45
46         operationEnd(true);
47     }
48
49     /**
50      * Transfer any handle locks to the db handle on success.
51      * On failure, leave it with this txn, the handle lock will
52      * be released at abort and the handle marked invalid.
53      */

54     public void setHandleLockOwner(boolean operationOK,
55                                    Database dbHandle,
56                                    boolean dbIsClosing)
57     throws DatabaseException {
58
59         if (operationOK) {
60             if (!dbIsClosing) {
61                 transferHandleLockToHandle(dbHandle);
62             }
63             unregisterHandle(dbHandle);
64         }
65     }
66 }
67
Popular Tags