1 21 22 package org.apache.derby.jdbc; 23 24 import org.apache.derby.iapi.services.info.JVMInfo; 25 26 import org.apache.derby.iapi.services.context.ContextService; 27 import org.apache.derby.iapi.services.monitor.ModuleControl; 28 import org.apache.derby.iapi.services.monitor.Monitor; 29 import org.apache.derby.iapi.services.sanity.SanityManager; 30 31 import org.apache.derby.iapi.jdbc.ResourceAdapter; 32 34 import org.apache.derby.iapi.error.StandardException; 35 import org.apache.derby.iapi.store.access.AccessFactory; 36 import org.apache.derby.iapi.store.access.xa.XAResourceManager; 37 import org.apache.derby.iapi.store.access.xa.XAXactId; 38 39 40 import java.util.Properties ; 41 import java.util.Hashtable ; 42 import java.util.Enumeration ; 43 44 45 public class ResourceAdapterImpl 46 implements ResourceAdapter, ModuleControl 47 { 48 private boolean active; 49 50 private XAResourceManager rm; 52 53 private Hashtable connectionTable; 55 56 59 60 public void boot(boolean create, Properties properties) 61 throws StandardException 62 { 63 66 connectionTable = new Hashtable (); 67 68 AccessFactory af = 69 (AccessFactory)Monitor.findServiceModule(this, AccessFactory.MODULE); 70 71 rm = (XAResourceManager) af.getXAResourceManager(); 72 73 active = true; 74 } 75 76 public void stop() 77 { 78 active = false; 79 80 for (Enumeration e = connectionTable.elements(); e.hasMoreElements(); ) { 81 82 XATransactionState tranState = (XATransactionState) e.nextElement(); 83 84 try { 85 tranState.conn.close(); 86 } catch (java.sql.SQLException sqle) { 87 } 88 } 89 90 active = false; 91 } 92 93 public boolean isActive() 94 { 95 return active; 96 } 97 98 101 102 public synchronized Object findConnection(XAXactId xid) { 103 104 return connectionTable.get(xid); 105 } 106 107 public synchronized boolean addConnection(XAXactId xid, Object conn) { 108 if (connectionTable.get(xid) != null) 109 return false; 110 111 connectionTable.put(xid, conn); 115 return true; 116 } 117 118 public synchronized Object removeConnection(XAXactId xid) { 119 120 return connectionTable.remove(xid); 121 122 } 123 124 125 128 public XAResourceManager getXAResourceManager() 129 { 130 return rm; 131 } 132 } 133 | Popular Tags |