01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: AutoTxn.java,v 1.27.2.3 2008/01/07 15:14:17 cwl Exp $
07: */
08:
09: 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() throws DatabaseException {
44:
45: operationEnd(true);
46: }
47:
48: /**
49: * Transfer any handle locks to the db handle on success.
50: * On failure, leave it with this txn, the handle lock will
51: * be released at abort and the handle marked invalid.
52: */
53: public void setHandleLockOwner(boolean operationOK,
54: Database dbHandle, boolean dbIsClosing)
55: throws DatabaseException {
56:
57: if (operationOK) {
58: if (!dbIsClosing) {
59: transferHandleLockToHandle(dbHandle);
60: }
61: unregisterHandle(dbHandle);
62: }
63: }
64: }
|