1 21 package oracle.toplink.essentials.exceptions; 23 24 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 25 import oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl; 26 27 public class TransactionException extends TopLinkException { 28 public static final int ERROR_DOING_JNDI_LOOKUP = 23001; 29 public static final int ERROR_GETTING_TRANSACTION_STATUS = 23002; 30 public static final int ERROR_GETTING_TRANSACTION = 23003; 31 public static final int ERROR_BINDING_TO_TRANSACTION = 23004; 32 public static final int ERROR_BEGINNING_TRANSACTION = 23005; 33 public static final int ERROR_COMMITTING_TRANSACTION = 23006; 34 public static final int ERROR_ROLLING_BACK_TRANSACTION = 23007; 35 public static final int ERROR_MARKING_TRANSACTION_FOR_ROLLBACK = 23008; 36 public static final int ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE = 23009; 37 public static final int ERROR_INACTIVE_UOW = 23010; 38 public static final int ERROR_OBTAINING_TRANSACTION_MANAGER = 23011; 39 public static final int ERROR_NO_TRANSACTION_ACTIVE = 23012; 40 public static final int ERROR_TRANSACTION_IS_ACTIVE = 23013; 41 public static final int ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED = 23014; 42 public static final int CANNOT_ENLIST_MULTIPLE_DATASOURCES = 23015; 43 public static final int EXCEPTION_IN_PROXY_EXECUTION= 23016; 44 45 public TransactionException(String message) { 46 super(message); 47 } 48 49 public TransactionException(String message, Exception internalException) { 50 super(message, internalException); 51 } 52 53 public static TransactionException jndiLookupException(String jndiName, Exception internalException) { 54 Object [] args = { jndiName }; 55 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_DOING_JNDI_LOOKUP, args)); 56 ex.setErrorCode(ERROR_DOING_JNDI_LOOKUP); 57 ex.setInternalException(internalException); 58 return ex; 59 } 60 61 public static TransactionException errorGettingExternalTransactionStatus(Exception internalException) { 62 Object [] args = { }; 63 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_GETTING_TRANSACTION_STATUS, args)); 64 ex.setErrorCode(ERROR_GETTING_TRANSACTION_STATUS); 65 ex.setInternalException(internalException); 66 return ex; 67 } 68 69 public static TransactionException errorGettingExternalTransaction(Exception internalException) { 70 Object [] args = { }; 71 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_GETTING_TRANSACTION, args)); 72 ex.setErrorCode(ERROR_GETTING_TRANSACTION); 73 ex.setInternalException(internalException); 74 return ex; 75 } 76 77 public static TransactionException errorBindingToExternalTransaction(Exception internalException) { 78 Object [] args = { }; 79 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_BINDING_TO_TRANSACTION, args)); 80 ex.setErrorCode(ERROR_BINDING_TO_TRANSACTION); 81 ex.setInternalException(internalException); 82 return ex; 83 } 84 85 public static TransactionException errorBeginningExternalTransaction(Exception internalException) { 86 Object [] args = { }; 87 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_BEGINNING_TRANSACTION, args)); 88 ex.setErrorCode(ERROR_BEGINNING_TRANSACTION); 89 ex.setInternalException(internalException); 90 return ex; 91 } 92 93 public static TransactionException errorCommittingExternalTransaction(Exception internalException) { 94 Object [] args = { }; 95 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_COMMITTING_TRANSACTION, args)); 96 ex.setErrorCode(ERROR_COMMITTING_TRANSACTION); 97 ex.setInternalException(internalException); 98 return ex; 99 } 100 101 public static TransactionException errorRollingBackExternalTransaction(Exception internalException) { 102 Object [] args = { }; 103 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_ROLLING_BACK_TRANSACTION, args)); 104 ex.setErrorCode(ERROR_ROLLING_BACK_TRANSACTION); 105 ex.setInternalException(internalException); 106 return ex; 107 } 108 109 public static TransactionException errorMarkingTransactionForRollback(Exception internalException) { 110 Object [] args = { }; 111 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_MARKING_TRANSACTION_FOR_ROLLBACK, args)); 112 ex.setErrorCode(ERROR_MARKING_TRANSACTION_FOR_ROLLBACK); 113 ex.setInternalException(internalException); 114 return ex; 115 } 116 117 public static TransactionException externalTransactionNotActive() { 118 Object [] args = { }; 119 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE, args)); 120 ex.setErrorCode(ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE); 121 return ex; 122 } 123 124 public static TransactionException inactiveUnitOfWork(UnitOfWorkImpl unitOfWork) { 125 Object [] args = { unitOfWork }; 126 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_INACTIVE_UOW, args)); 127 ex.setErrorCode(ERROR_INACTIVE_UOW); 128 return ex; 129 } 130 131 public static TransactionException errorObtainingTransactionManager(Exception internalException) { 132 Object [] args = { }; 133 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_OBTAINING_TRANSACTION_MANAGER, args)); 134 ex.setErrorCode(ERROR_OBTAINING_TRANSACTION_MANAGER); 135 ex.setInternalException(internalException); 136 return ex; 137 } 138 139 public static TransactionException transactionNotActive() { 140 Object [] args = { }; 141 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_NO_TRANSACTION_ACTIVE, args)); 142 ex.setErrorCode(ERROR_NO_TRANSACTION_ACTIVE); 143 return ex; 144 } 145 public static TransactionException transactionIsActive() { 146 Object [] args = { }; 147 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_TRANSACTION_IS_ACTIVE, args)); 148 ex.setErrorCode(ERROR_TRANSACTION_IS_ACTIVE); 149 return ex; 150 } 151 152 public static TransactionException entityTransactionWithJTANotAllowed() { 153 Object [] args = { }; 154 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED, args)); 155 ex.setErrorCode(ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED); 156 return ex; 157 } 158 159 public static TransactionException multipleResourceException() { 160 Object [] args = { }; 161 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, CANNOT_ENLIST_MULTIPLE_DATASOURCES, args)); 162 ex.setErrorCode(CANNOT_ENLIST_MULTIPLE_DATASOURCES); 163 return ex; 164 } 165 166 public static TransactionException internalProxyException(Exception ex1) { 167 Object [] args = { }; 168 TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, EXCEPTION_IN_PROXY_EXECUTION, args), ex1); 169 ex.setErrorCode(EXCEPTION_IN_PROXY_EXECUTION); 170 return ex; 171 } 172 } 173 | Popular Tags |