01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.persistence.sleepycat;
06:
07: import com.sleepycat.je.DatabaseException;
08: import com.sleepycat.je.Environment;
09: import com.sleepycat.je.Transaction;
10: import com.tc.objectserver.persistence.api.PersistenceTransaction;
11: import com.tc.objectserver.persistence.api.PersistenceTransactionProvider;
12:
13: final class SleepycatPersistenceTransactionProvider implements
14: PersistenceTransactionProvider {
15: private static final PersistenceTransaction NULL_TRANSACTION = new TransactionWrapper(
16: null);
17: private final Environment env;
18:
19: public SleepycatPersistenceTransactionProvider(Environment env) {
20: this .env = env;
21: }
22:
23: public PersistenceTransaction newTransaction() {
24: try {
25: return new TransactionWrapper(newNativeTransaction());
26: } catch (DatabaseException e) {
27: throw new DBException(e);
28: }
29: }
30:
31: public PersistenceTransaction nullTransaction() {
32: return NULL_TRANSACTION;
33: }
34:
35: private Transaction newNativeTransaction() throws DatabaseException {
36: return this.env.beginTransaction(null, null);
37: }
38: }
|