[jboss-svn-commits] JBL Code SVN: r19554 - labs/jbossesb/branches/JBESB_4_2_1_GA_CP2/product/rosetta/src/org/jboss/internal/soa/esb/couriers.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Apr 14 14:08:22 EDT 2008


Author: tfennelly
Date: 2008-04-14 14:08:22 -0400 (Mon, 14 Apr 2008)
New Revision: 19554

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP2/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
Log:
Just pulled the "isTransactional" code into a provate method.

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP2/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP2/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-04-14 17:51:27 UTC (rev 19553)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP2/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-04-14 18:08:22 UTC (rev 19554)
@@ -130,31 +130,8 @@
 			throw new CourierException("Problems with message header ",e);
 		}
 
-        boolean transactional;
-        try
-		{
-            TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
-            Object txHandle = ((txStrategy == null) ? null : txStrategy.getTransaction());
-            boolean isActive = ((txStrategy == null) ? false : txStrategy.isActive());
+        boolean transactional = isTransactional();
 
-            transactional = (txHandle != null);
-
-            /*
-             * Make sure the current transaction is still active! If we
-             * have previously slept, then the timeout may be longer than that
-             * associated with the transaction.
-             */
-
-            if (transactional && !isActive)
-            {
-                throw new CourierException("Associated transaction is no longer active!");
-            }
-		}
-		catch (TransactionStrategyException ex)
-		{
-		    throw new CourierException(ex);
-		}
-
         Serializable serilaizedMessage;
         try {
             serilaizedMessage = Util.serialize(message);
@@ -217,39 +194,7 @@
 
 		do
 		{
-            boolean transactional;
-            try
-			{
-				TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
-				Object txHandle = ((txStrategy == null) ? null : txStrategy.getTransaction());
-				boolean isActive = ((txStrategy == null) ? false : txStrategy.isActive());
-
-				transactional = (txHandle != null);
-
-				/*
-				 * Make sure the current transaction is still active! If we
-				 * have previously slept, then the timeout may be longer than that
-				 * associated with the transaction.
-				 */
-
-				/*
-				 * MessageAwareListener will catch exceptions and roll back the transaction.
-				 */
-
-				if (transactional && !isActive)
-				{
-				    _logger.error("SqlTableCourier - associated transaction is no longer active!");
-
-				    throw new CourierException("Associated transaction is no longer active!");
-				}
-			}
-			catch (TransactionStrategyException ex)
-			{
-				_logger.error("Could not determine transaction association!", ex);
-
-				throw new CourierException("Could not determine transaction association!");
-			}
-
+            boolean transactional = isTransactional();
             Connection connection = jdbcFactory.createConnection(transactional);
             try {
                 PreparedStatement listStatement = jdbcFactory.createListStatement(connection);
@@ -420,6 +365,7 @@
 		{
 			return toString().substring(0, 1);
 		}
+
     }
 
     public void setPollLatency(Long millis)
@@ -429,4 +375,32 @@
 		else
 			_pollLatency = millis;
 	}
+
+    private boolean isTransactional() throws CourierException {
+        boolean transactional;
+        try
+        {
+            TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
+            Object txHandle = ((txStrategy == null) ? null : txStrategy.getTransaction());
+            boolean isActive = ((txStrategy == null) ? false : txStrategy.isActive());
+
+            transactional = (txHandle != null);
+
+            /*
+            * Make sure the current transaction is still active! If we
+            * have previously slept, then the timeout may be longer than that
+            * associated with the transaction.
+            */
+
+            if (transactional && !isActive)
+            {
+                throw new CourierException("Associated transaction is no longer active!");
+            }
+        }
+        catch (TransactionStrategyException ex)
+        {
+            throw new CourierException(ex);
+        }
+        return transactional;
+    }
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list