You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2005/02/16 01:02:58 UTC
svn commit: r153979 - in geronimo/trunk/modules:
client/src/java/org/apache/geronimo/client/
transaction/src/java/org/apache/geronimo/transaction/
transaction/src/java/org/apache/geronimo/transaction/context/
Author: dain
Date: Tue Feb 15 16:02:56 2005
New Revision: 153979
URL: http://svn.apache.org/viewcvs?view=rev&rev=153979
Log:
Changed transaction context commit to return a boolean indicating if the transation actually committed.
UserTransaction uses the boolean flag to determine if the tx rolledback and if so, throws a RolledbackException
Modified:
geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java
geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java
geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java
Modified: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java?view=diff&r1=153978&r2=153979
==============================================================================
--- geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java (original)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java Tue Feb 15 16:02:56 2005
@@ -24,6 +24,7 @@
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.transaction.context.TransactionContext;
import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
@@ -79,7 +80,7 @@
ClassLoader contextClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader(classLoader);
TransactionContext oldTransactionContext = transactionContextManager.getContext();
- TransactionContext currentTransactionContext = null;
+ UnspecifiedTransactionContext currentTransactionContext = null;
try {
jndiContext.startClient(appClientModuleName, kernel, classLoader);
currentTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java?view=diff&r1=153978&r2=153979
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java Tue Feb 15 16:02:56 2005
@@ -64,7 +64,9 @@
}
BeanTransactionContext beanContext = (BeanTransactionContext) ctx;
try {
- beanContext.commit();
+ if (!beanContext.commit()) {
+ throw new RollbackException();
+ }
} finally {
UnspecifiedTransactionContext oldContext = beanContext.getOldContext();
transactionContextManager.setContext(oldContext);
Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java?view=diff&r1=153978&r2=153979
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java Tue Feb 15 16:02:56 2005
@@ -99,19 +99,25 @@
threadAssociated = true;
}
- public void commit() throws HeuristicMixedException, HeuristicRollbackException, SystemException, RollbackException {
+ public boolean commit() throws HeuristicMixedException, HeuristicRollbackException, SystemException, RollbackException {
boolean wasCommitted = false;
try {
- checkRolledback();
+ if (isRolledback()) {
+ return false;
+ }
flushState();
- checkRolledback();
+ if (isRolledback()) {
+ return false;
+ }
// todo we need to flush anyone enrolled during before and then call before on any flushed...
beforeCommit();
- checkRolledback();
+ if (isRolledback()) {
+ return false;
+ }
txnManager.commit();
wasCommitted = true;
@@ -127,9 +133,10 @@
transaction = null;
}
}
+ return wasCommitted;
}
- private void checkRolledback() throws SystemException, RollbackException {
+ private boolean isRolledback() throws SystemException {
int status;
try {
status = transaction.getStatus();
@@ -141,12 +148,13 @@
if (status == Status.STATUS_MARKED_ROLLBACK) {
// we need to rollback
txnManager.rollback();
- throw new RollbackException();
+ return true;
} else if (status == Status.STATUS_ROLLEDBACK ||
status == Status.STATUS_ROLLING_BACK) {
// already rolled back
- throw new RollbackException();
+ return true;
}
+ return false;
}
private void rollbackAndThrow(String message, Throwable throwable) throws HeuristicMixedException, HeuristicRollbackException, SystemException, RollbackException {
Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java?view=diff&r1=153978&r2=153979
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java Tue Feb 15 16:02:56 2005
@@ -59,13 +59,11 @@
private Map managedConnections;
private InTxCache inTxCache;
-// public abstract void begin() throws SystemException, NotSupportedException;
-
public abstract void suspend() throws SystemException;
public abstract void resume() throws SystemException, InvalidTransactionException;
- public abstract void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException;
+ public abstract boolean commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException;
public abstract void rollback() throws SystemException;
Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java?view=diff&r1=153978&r2=153979
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java Tue Feb 15 16:02:56 2005
@@ -18,7 +18,6 @@
package org.apache.geronimo.transaction.context;
import javax.transaction.Transaction;
-import javax.transaction.SystemException;
import org.apache.geronimo.transaction.ConnectionReleaser;
@@ -36,7 +35,7 @@
public void resume() {
}
- public void commit() {
+ public boolean commit() {
try {
flushState();
} catch (Error e) {
@@ -46,6 +45,7 @@
} catch (Throwable e) {
log.error("Unable to flush state, continuing", e);
}
+ return true;
}
public void rollback() {