1 package org.apache.ojb.jdo; 2 3 17 18 import org.apache.ojb.otm.OTMKit; 19 import org.apache.ojb.otm.OTMConnection; 20 21 import javax.jdo.Transaction; 22 import javax.jdo.PersistenceManager; 23 import javax.jdo.JDOUserException; 24 import javax.jdo.JDOUnsupportedOptionException; 25 import javax.transaction.Synchronization ; 26 27 31 public class TransactionImpl implements Transaction 32 { 33 private PersistenceManager m_pm; 34 private OTMKit m_kit; 35 private OTMConnection m_conn; 36 37 public TransactionImpl(PersistenceManager pm, OTMKit kit, OTMConnection conn) 38 { 39 m_pm = pm; 40 m_conn = conn; 41 m_kit = kit; 42 } 43 44 public void begin() 45 { 46 if (m_kit.getTransaction(m_conn).isInProgress()) 47 { 48 throw new JDOUserException("Transaction already in progress"); 49 } 50 m_kit.getTransaction(m_conn).begin(); 51 } 52 53 public void commit() 54 { 55 if (!m_kit.getTransaction(m_conn).isInProgress()) 56 { 57 throw new JDOUserException("Transaction not in progress"); 58 } 59 m_kit.getTransaction(m_conn).commit(); 60 } 61 62 public void rollback() 63 { 64 if (!m_kit.getTransaction(m_conn).isInProgress()) 65 { 66 throw new JDOUserException("Transaction not in progress"); 67 } 68 m_kit.getTransaction(m_conn).rollback(); 69 } 70 71 public boolean isActive() 72 { 73 return m_kit.getTransaction(m_conn).isInProgress(); 74 } 75 76 public void setNontransactionalRead(boolean b) 77 { 78 throw new javax.jdo.JDOUnsupportedOptionException("Unsupported"); 79 } 80 81 public boolean getNontransactionalRead() 82 { 83 return false; 84 } 85 86 public void setNontransactionalWrite(boolean b) 87 { 88 throw new javax.jdo.JDOUnsupportedOptionException("Unsupported"); 89 } 90 91 public boolean getNontransactionalWrite() 92 { 93 return false; 94 } 95 96 99 public void setRetainValues(boolean b) 100 { 101 } 103 104 public boolean getRetainValues() 105 { 106 return true; 107 } 108 109 112 public void setRestoreValues(boolean b) 113 { 114 throw new JDOUnsupportedOptionException("Not Yet Implemented"); 115 } 116 117 120 public boolean getRestoreValues() 121 { 122 return false; 123 } 124 125 128 public void setOptimistic(boolean b) 129 { 130 throw new JDOUnsupportedOptionException("Not yet implemented"); 131 } 132 133 136 public boolean getOptimistic() 137 { 138 return false; 139 } 140 141 145 public void setSynchronization(Synchronization synchronization) 146 { 147 throw new JDOUnsupportedOptionException("Not Yet Implemented"); 148 } 149 150 153 public Synchronization getSynchronization() 154 { 155 throw new JDOUnsupportedOptionException("Not Yet Implemented"); 156 } 157 158 public PersistenceManager getPersistenceManager() 159 { 160 return m_pm; 161 } 162 } 163 | Popular Tags |