geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54014 - geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work
Date Thu, 07 Oct 2004 20:50:39 GMT
Author: djencks
Date: Thu Oct  7 13:50:39 2004
New Revision: 54014

Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/WorkerContext.java
Log:
Throw correct exceptions when xid import fails or concurrent work is attempted

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/WorkerContext.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/WorkerContext.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/work/WorkerContext.java
Thu Oct  7 13:50:39 2004
@@ -26,11 +26,15 @@
 import javax.resource.spi.work.WorkListener;
 import javax.resource.spi.work.WorkManager;
 import javax.resource.spi.work.WorkRejectedException;
+import javax.transaction.xa.XAException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
 
 import EDU.oswego.cs.dl.util.concurrent.Latch;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.ImportedTransactionActiveException;
 
 /**
  * Work wrapper providing an execution context to a Work instance.
@@ -291,6 +295,16 @@
             } else {
                 try {
                     transactionContextManager.begin(executionContext.getXid(), executionContext.getTransactionTimeout());
+                } catch (XAException e) {
+                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+               } catch (InvalidTransactionException e) {
+                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+               } catch (SystemException e) {
+                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+                } catch (ImportedTransactionActiveException e) {
+                    throw new WorkCompletedException("Transaction already active for xid
" + executionContext.getXid(), WorkCompletedException.TX_CONCURRENT_WORK_DISALLOWED);
+                }
+                try {
                     adaptee.run();
                 } finally {
                     transactionContextManager.end(executionContext.getXid());
@@ -300,8 +314,8 @@
             workListener.workCompleted(
                     new WorkEvent(this, WorkEvent.WORK_COMPLETED, adaptee, null));
         } catch (Throwable e) {
-            workException = new WorkCompletedException(e);
-            workListener.workRejected(
+            workException =  (WorkException) (e instanceof WorkCompletedException? e: new
WorkCompletedException("Unknown error", WorkCompletedException.UNDEFINED).initCause(e));
+            workListener.workCompleted(
                     new WorkEvent(this, WorkEvent.WORK_REJECTED, adaptee,
                             workException));
         } finally {

Mime
View raw message