[exo-jcr-commits] exo-jcr SVN: r1399 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jan 14 15:14:37 EST 2010


Author: nfilotto
Date: 2010-01-14 15:14:36 -0500 (Thu, 14 Jan 2010)
New Revision: 1399

Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-334: Avoid to set the default timeout to the TM, if the value doesn't come from the configuration. We assume that the value of the timeout is managed directly by the AS

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java	2010-01-14 17:11:58 UTC (rev 1398)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java	2010-01-14 20:14:36 UTC (rev 1399)
@@ -60,6 +60,11 @@
    protected final int defaultTimeout;
    
    /**
+    * Indicates if the timeout has to be enforced
+    */
+   protected final boolean forceTimeout;
+   
+   /**
     * The current Transaction Manager
     */
    private volatile TransactionManager tm; 
@@ -80,10 +85,12 @@
       if (params != null && params.getValueParam("timeout") != null)
       {
          this.defaultTimeout = Integer.parseInt(params.getValueParam("timeout").getValue());
+         this.forceTimeout = true;
       }
       else
       {
          this.defaultTimeout = DEFAULT_TIME_OUT;
+         this.forceTimeout = false;
       }
    }
 
@@ -108,7 +115,7 @@
       }
       else
       {
-         delistResource(tm, exores);
+         delistResourceOnTxMissing(tm, exores);
       }
    }
 
@@ -156,15 +163,21 @@
                catch (Exception e)
                {
                   throw new RuntimeException("Transaction manager not found", e);
-               }        
-               try
+               }
+               if (forceTimeout)
                {
-                  tm.setTransactionTimeout(defaultTimeout);
+                  // Only set the timeout when a timeout has been given into the
+                  // configuration otherwise we assume that the value will be
+                  // set at the AS level
+                  try
+                  {
+                     tm.setTransactionTimeout(defaultTimeout);
+                  }
+                  catch (Exception e)
+                  {
+                     log.warn("Cannot set the transaction timeout", e);
+                  }                  
                }
-               catch (Exception e)
-               {
-                  log.warn("Cannot set the transaction timeout", e);
-               }        
                this.tm = tm;
             }
          }
@@ -201,7 +214,7 @@
     * Allows to execute an action when we try to delist a resource when there is no active 
     * transaction
     */
-   protected void delistResource(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+   protected void delistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
    {
    }
 }



More information about the exo-jcr-commits mailing list