1 package org.apache.ojb.odmg; 2 3 17 18 import java.util.Hashtable ; 19 20 import org.apache.ojb.broker.util.configuration.Configuration; 21 import org.odmg.TransactionNotInProgressException; 22 23 31 public class LocalTxManager implements OJBTxManager 32 { 33 41 private static TransactionTable tx_table = new TransactionTable(); 42 43 public LocalTxManager() 44 { 45 46 } 47 48 54 public TransactionImpl getCurrentTransaction() 55 { 56 TransactionImpl tx = tx_table.get(Thread.currentThread()); 57 if(tx == null) 58 { 59 throw new TransactionNotInProgressException("Calling method needed transaction, but no transaction found for current thread :-("); 60 } 61 return tx; 62 } 63 64 68 public TransactionImpl getTransaction() 69 { 70 return tx_table.get(Thread.currentThread()); 71 } 72 73 76 public void registerTx(TransactionImpl tx) 77 { 78 tx_table.put(Thread.currentThread(), tx); 79 } 80 81 84 public void deregisterTx(Object token) 85 { 86 tx_table.remove(Thread.currentThread()); 87 } 88 89 92 public void abortExternalTx(TransactionImpl odmgTrans) 93 { 94 97 } 98 99 public void configure(Configuration config) 100 { 101 102 } 103 104 105 118 static final class TransactionTable 119 { 120 123 private Hashtable m_table = new Hashtable (); 124 125 128 public TransactionTable() 129 { 130 } 131 132 138 public TransactionImpl get(Thread key_thread) 139 { 140 return (TransactionImpl) m_table.get(key_thread); 141 } 142 143 149 public void put(Thread key_thread, TransactionImpl value_tx) 150 { 151 m_table.put(key_thread, value_tx); 152 } 153 154 159 public void remove(Thread key_thread) 160 { 161 m_table.remove(key_thread); 162 } 163 } 164 } 165 | Popular Tags |