1 4 package com.tc.objectserver.persistence.sleepycat; 5 6 import com.sleepycat.je.DatabaseException; 7 import com.sleepycat.je.Environment; 8 import com.sleepycat.je.Transaction; 9 import com.tc.objectserver.persistence.api.PersistenceTransaction; 10 import com.tc.objectserver.persistence.api.PersistenceTransactionProvider; 11 12 final class SleepycatPersistenceTransactionProvider implements PersistenceTransactionProvider { 13 private static final PersistenceTransaction NULL_TRANSACTION = new TransactionWrapper(null); 14 private final Environment env; 15 16 public SleepycatPersistenceTransactionProvider(Environment env) { 17 this.env = env; 18 } 19 20 public PersistenceTransaction newTransaction() { 21 try { 22 return new TransactionWrapper(newNativeTransaction()); 23 } catch (DatabaseException e) { 24 throw new DBException(e); 25 } 26 } 27 28 public PersistenceTransaction nullTransaction() { 29 return NULL_TRANSACTION; 30 } 31 32 Transaction newNativeTransaction() throws DatabaseException { 33 return this.env.beginTransaction(null, null); 34 } 35 } | Popular Tags |