summaryrefslogtreecommitdiff
path: root/java/src/Freeze/TransactionI.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2003-09-16 01:41:46 +0000
committerBernard Normier <bernard@zeroc.com>2003-09-16 01:41:46 +0000
commit83cb29a8de333646c9b3e7ac6909accce72e6b5f (patch)
treecc1037886e0d1770d9c1ad412d79c81a5a1d21ad /java/src/Freeze/TransactionI.java
parentflex fixes (diff)
downloadice-83cb29a8de333646c9b3e7ac6909accce72e6b5f.tar.bz2
ice-83cb29a8de333646c9b3e7ac6909accce72e6b5f.tar.xz
ice-83cb29a8de333646c9b3e7ac6909accce72e6b5f.zip
Added Freeze Connection and Transaction
Diffstat (limited to 'java/src/Freeze/TransactionI.java')
-rwxr-xr-xjava/src/Freeze/TransactionI.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/java/src/Freeze/TransactionI.java b/java/src/Freeze/TransactionI.java
new file mode 100755
index 00000000000..2a6e43939cc
--- /dev/null
+++ b/java/src/Freeze/TransactionI.java
@@ -0,0 +1,107 @@
+// **********************************************************************
+//
+// Copyright (c) 2003
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+package Freeze;
+
+class TransactionI extends Ice.LocalObjectImpl implements Transaction
+{
+ public void
+ commit()
+ {
+ try
+ {
+ _connection.closeAllIterators();
+ _txn.commit(0);
+ }
+ catch(com.sleepycat.db.DbDeadlockException e)
+ {
+ DBDeadlockException ex = new DBDeadlockException();
+ ex.initCause(e);
+ ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
+ throw ex;
+ }
+ catch(com.sleepycat.db.DbException e)
+ {
+ DBException ex = new DBException();
+ ex.initCause(e);
+ ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
+ throw ex;
+ }
+ finally
+ {
+ _connection.clearTransaction();
+ _connection = null;
+ _txn = null;
+ }
+ }
+
+ public void
+ rollback()
+ {
+ try
+ {
+ _connection.closeAllIterators();
+ _txn.abort();
+ }
+ catch(com.sleepycat.db.DbDeadlockException e)
+ {
+ DBDeadlockException ex = new DBDeadlockException();
+ ex.initCause(e);
+ ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage();
+ throw ex;
+ }
+ catch(com.sleepycat.db.DbException e)
+ {
+ DBException ex = new DBException();
+ ex.initCause(e);
+ ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage();
+ throw ex;
+ }
+ finally
+ {
+ _connection.clearTransaction();
+ _connection = null;
+ _txn = null;
+ }
+ }
+
+ TransactionI(ConnectionI connection)
+ {
+ _connection = connection;
+ _errorPrefix = "Freeze DB DbEnv(\"" + _connection.envName() + "\") :";
+
+ try
+ {
+ _txn = _connection.dbEnv().txn_begin(null, 0);
+ }
+ catch(com.sleepycat.db.DbException e)
+ {
+ DBException ex = new DBException();
+ ex.initCause(e);
+ ex.message = _errorPrefix + "txn_begin: " + e.getMessage();
+ throw ex;
+ }
+ }
+
+ com.sleepycat.db.DbTxn
+ dbTxn()
+ {
+ return _txn;
+ }
+
+ private ConnectionI _connection;
+ private com.sleepycat.db.DbTxn _txn;
+
+ private String _errorPrefix;
+}