1 16 17 package org.springframework.transaction.support; 18 19 import org.springframework.transaction.NestedTransactionNotSupportedException; 20 import org.springframework.transaction.SavepointManager; 21 22 49 public class DefaultTransactionStatus extends AbstractTransactionStatus { 50 51 private final Object transaction; 52 53 private final boolean newTransaction; 54 55 private final boolean newSynchronization; 56 57 private final boolean readOnly; 58 59 private final boolean debug; 60 61 private final Object suspendedResources; 62 63 64 79 public DefaultTransactionStatus( 80 Object transaction, boolean newTransaction, boolean newSynchronization, 81 boolean readOnly, boolean debug, Object suspendedResources) { 82 83 this.transaction = transaction; 84 this.newTransaction = newTransaction; 85 this.newSynchronization = newSynchronization; 86 this.readOnly = readOnly; 87 this.debug = debug; 88 this.suspendedResources = suspendedResources; 89 } 90 91 94 public Object getTransaction() { 95 return this.transaction; 96 } 97 98 101 public boolean hasTransaction() { 102 return (this.transaction != null); 103 } 104 105 public boolean isNewTransaction() { 106 return (hasTransaction() && this.newTransaction); 107 } 108 109 113 public boolean isNewSynchronization() { 114 return this.newSynchronization; 115 } 116 117 120 public boolean isReadOnly() { 121 return this.readOnly; 122 } 123 124 129 public boolean isDebug() { 130 return this.debug; 131 } 132 133 137 public Object getSuspendedResources() { 138 return this.suspendedResources; 139 } 140 141 142 146 153 public boolean isGlobalRollbackOnly() { 154 return ((this.transaction instanceof SmartTransactionObject) && 155 ((SmartTransactionObject) this.transaction).isRollbackOnly()); 156 } 157 158 162 protected SavepointManager getSavepointManager() { 163 if (!isTransactionSavepointManager()) { 164 throw new NestedTransactionNotSupportedException( 165 "Transaction object [" + getTransaction() + "] does not support savepoints"); 166 } 167 return (SavepointManager) getTransaction(); 168 } 169 170 176 public boolean isTransactionSavepointManager() { 177 return (getTransaction() instanceof SavepointManager); 178 } 179 180 } 181 | Popular Tags |