1 23 24 28 29 package com.sun.jts.jta; 30 31 import javax.transaction.*; 32 import javax.naming.*; 33 import java.util.Properties ; 34 35 import java.util.logging.Logger ; 36 import java.util.logging.Level ; 37 import com.sun.logging.LogDomains; 38 46 public class UserTransactionImpl implements javax.transaction.UserTransaction , 47 javax.naming.Referenceable , java.io.Serializable { 48 49 51 private transient TransactionManager transactionManager; 52 53 56 static Logger _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER); 57 59 public UserTransactionImpl() {} 60 61 63 73 public void begin() throws NotSupportedException, SystemException { 74 if (transactionManager == null) init(); 75 this.transactionManager.begin(); 76 } 77 78 102 public void commit() throws RollbackException, 103 HeuristicMixedException, HeuristicRollbackException, SecurityException , 104 IllegalStateException , SystemException { 105 if (transactionManager == null) init(); 106 this.transactionManager.commit(); 107 } 108 109 123 public void rollback() throws IllegalStateException , SecurityException , 124 SystemException { 125 if (transactionManager == null) init(); 126 this.transactionManager.rollback(); 127 } 128 129 141 public void setRollbackOnly() throws IllegalStateException , 142 SystemException { 143 if (transactionManager == null) init(); 144 this.transactionManager.setRollbackOnly(); 145 } 146 147 158 public int getStatus() throws SystemException { 159 if (transactionManager == null) init(); 160 return this.transactionManager.getStatus(); 161 } 162 163 178 public void setTransactionTimeout(int seconds) throws SystemException { 179 if (transactionManager == null) init(); 180 this.transactionManager.setTransactionTimeout(seconds); 181 } 182 183 185 188 public Reference getReference() throws NamingException { 189 return new Reference(this.getClass().getName(), 191 UserTransactionFactory.class.getName(), null); 192 } 193 194 196 197 private void init() { 198 this.transactionManager = 199 TransactionManagerImpl.getTransactionManagerImpl(); 200 } 201 } 202 203 | Popular Tags |