1 8 9 package com.sleepycat.je.jca.ra; 10 11 import javax.resource.ResourceException ; 12 13 import com.sleepycat.je.Database; 14 import com.sleepycat.je.DatabaseConfig; 15 import com.sleepycat.je.DatabaseException; 16 import com.sleepycat.je.Environment; 17 import com.sleepycat.je.SecondaryConfig; 18 import com.sleepycat.je.SecondaryDatabase; 19 import com.sleepycat.je.Transaction; 20 21 27 public class JEConnection { 28 29 private JEManagedConnection mc; 30 private JELocalTransaction txn; 31 32 public JEConnection(JEManagedConnection mc) { 33 this.mc = mc; 34 } 35 36 protected void setManagedConnection(JEManagedConnection mc, 37 JELocalTransaction lt) { 38 this.mc = mc; 39 if (txn == null) { 40 txn = lt; 41 } 42 } 43 44 JELocalTransaction getLocalTransaction() { 45 return txn; 46 } 47 48 void setLocalTransaction(JELocalTransaction txn) { 49 this.txn = txn; 50 } 51 52 public Environment getEnvironment() 53 throws ResourceException { 54 55 return mc.getEnvironment(); 56 } 57 58 public Database openDatabase(String name, DatabaseConfig config) 59 throws DatabaseException { 60 61 return mc.openDatabase(name, config); 62 } 63 64 public SecondaryDatabase openSecondaryDatabase(String name, 65 Database primaryDatabase, 66 SecondaryConfig config) 67 throws DatabaseException { 68 69 return mc.openSecondaryDatabase(name, primaryDatabase, config); 70 } 71 72 public void removeDatabase(String databaseName) 73 throws DatabaseException { 74 75 mc.removeDatabase(databaseName); 76 } 77 78 public long truncateDatabase(String databaseName, boolean returnCount) 79 throws DatabaseException { 80 81 return mc.truncateDatabase(databaseName, returnCount); 82 } 83 84 public Transaction getTransaction() 85 throws ResourceException { 86 87 if (txn == null) { 88 return null; 89 } 90 91 try { 92 return txn.getTransaction(); 93 } catch (DatabaseException DE) { 94 ResourceException ret = new ResourceException (DE.toString()); 95 ret.initCause(DE); 96 throw ret; 97 } 98 } 99 100 public void close() 101 throws JEException { 102 103 mc.close(); 104 } 105 } 106 | Popular Tags |