[exo-jcr-commits] exo-jcr SVN: r1382 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jan 13 16:34:21 EST 2010


Author: nfilotto
Date: 2010-01-13 16:34:21 -0500 (Wed, 13 Jan 2010)
New Revision: 1382

Added:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Removed:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java
Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-334: Finish implementing XA Transaction

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -34,12 +34,14 @@
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.RepositoryException;
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
+import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
 /**
@@ -398,116 +400,186 @@
     * {@inheritDoc}
     */
    @Override
-   public void save(ItemStateChangesLog changesLog) throws RepositoryException
+   public void save(final ItemStateChangesLog changesLog) throws RepositoryException
    {
       if (transactionManager == null)
       {
          super.save(changesLog);
+
+         // notify listeners after transaction commit         
+         notifySaveItems(changesLog, false);              
       }
       else
       {
          try
          {
-            transactionManager.begin();
-            transactionManager.setTransactionTimeout(20); // TODO manage it via the confguration
-            cache.beginTransaction(); // TODO keep it into the cache impl
-            super.save(changesLog);
-            cache.commitTransaction();
-            transactionManager.commit();
+            if (transactionManager.getStatus() == Status.STATUS_COMMITTING)
+            {
+               // The JCR session has been enrolled into a XA Transaction, the method applyChanges must be called in another thread since the operations
+               // that we do into the cache are not allowed within the current Transaction, so to do it in another Transaction we need to call the method
+               // from another Thread
+               final AtomicReference<Exception> exception = new AtomicReference<Exception>();
+               final CountDownLatch doneSignal = new CountDownLatch(1);
+               Thread t = new Thread()
+               {
+                  public void run()
+                  {
+                     try
+                     {
+                        applyChanges(changesLog);
+                     }
+                     catch (Exception e)
+                     {
+                        exception.set(e);
+                     }
+                     finally
+                     {
+                        doneSignal.countDown();
+                     }
+                  }
+               };
+               t.start();
+               doneSignal.await();
+               Exception e = exception.get();
+               if (e != null)
+               {
+                  if (e instanceof RepositoryException)
+                  {
+                     throw (RepositoryException)e;                     
+                  }
+                  else
+                  {
+                     throw new RuntimeException(e);
+                  }
+               }
+            }
+            else
+            {
+               // Normal Transaction
+               applyChanges(changesLog);
+            }
          }
-         catch (RollbackException e)
+         catch (RepositoryException e)
          {
-            // Indicate that the transaction has been rolled back rather than committed.
-            throw new RepositoryException(e);
+            throw e;
          }
-         catch (JCRInvalidItemStateException e)
+         catch (InterruptedException e)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+         }
+         catch (SystemException e)
+         {
+            throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+         }
+      }
+   } 
 
-            throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+   /**
+    * Apply all the current changes
+    */
+   private void applyChanges(ItemStateChangesLog changesLog) throws RepositoryException
+   {
+      try
+      {
+         transactionManager.begin();
+         transactionManager.setTransactionTimeout(20); // TODO manage it via the configuration
+         cache.beginTransaction(); // TODO keep it into the cache impl
+         super.save(changesLog);
+         cache.commitTransaction();
+         transactionManager.commit();
+      }
+      catch (RollbackException e)
+      {
+         // Indicate that the transaction has been rolled back rather than committed.
+         throw new RepositoryException(e);
+      }
+      catch (JCRInvalidItemStateException e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
-         catch (InvalidItemStateException e)
+         catch (Exception e1)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            LOG.error("Rollback error ", e1);
+         }
 
-            throw new InvalidItemStateException(e);
+         throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+      }
+      catch (InvalidItemStateException e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
-         catch (ItemExistsException e)
+         catch (Exception e1)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            LOG.error("Rollback error ", e1);
+         }
 
-            throw new ItemExistsException(e);
+         throw new InvalidItemStateException(e);
+      }
+      catch (ItemExistsException e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
-         catch (ReadOnlyWorkspaceException e)
+         catch (Exception e1)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            LOG.error("Rollback error ", e1);
+         }
 
-            throw new ReadOnlyWorkspaceException(e);
+         throw new ItemExistsException(e);
+      }
+      catch (ReadOnlyWorkspaceException e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
-         catch (RepositoryException e)
+         catch (Exception e1)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            LOG.error("Rollback error ", e1);
+         }
 
-            throw new RepositoryException(e);
+         throw new ReadOnlyWorkspaceException(e);
+      }
+      catch (RepositoryException e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
-         catch (Exception e)
+         catch (Exception e1)
          {
-            try
-            {
-               cache.rollbackTransaction();
-               transactionManager.rollback();
-            }
-            catch (Exception e1)
-            {
-               LOG.error("Rollback error ", e1);
-            }
+            LOG.error("Rollback error ", e1);
+         }
 
-            throw new RepositoryException(e);
+         throw new RepositoryException(e);
+      }
+      catch (Exception e)
+      {
+         try
+         {
+            cache.rollbackTransaction();
+            transactionManager.rollback();
          }
+         catch (Exception e1)
+         {
+            LOG.error("Rollback error ", e1);
+         }
+
+         throw new RepositoryException(e);
       }
 
       // notify listeners after transaction commit         
-      notifySaveItems(changesLog, false);
+      notifySaveItems(changesLog, false);      
    }
 
    /**

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -297,6 +297,10 @@
       CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
       LOG.info("JBoss Cache configuration used: " + jbcConfig);
       this.cache = new BufferedJBossCache(factory.createCache(jbcConfig, false));
+      if (transactionManager != null)
+      {
+         cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);         
+      }
 
       this.cache.create();
       this.cache.start();

Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.transaction.jbosscache;
+
+import com.arjuna.ats.jta.xa.XidImple;
+
+import org.exoplatform.container.xml.InitParams;
+import org.jboss.cache.transaction.TransactionManagerLookup;
+
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.Xid;
+
+/**
+ * Add the specific part for Arjuna
+ * 
+ * @author <a href="mailto:nicolas.filotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ArjunaTransactionService extends GenericTransactionService
+{
+   
+   public ArjunaTransactionService(TransactionManagerLookup tmLookup)
+   {
+      super(tmLookup);
+   }
+      
+   public ArjunaTransactionService(TransactionManagerLookup tmLookup, InitParams params)
+   {
+      super(tmLookup, params);      
+   }
+
+   /**
+    * {@inheritDoc} 
+    */
+   @Override
+   public Xid createXid()
+   {
+      return new XidImple();
+   }
+
+   /**
+    * {@inheritDoc} 
+    */
+   @Override
+   public UserTransaction getUserTransaction()
+   {
+      return com.arjuna.ats.jta.UserTransaction.userTransaction();
+   }
+}

Added: 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	                        (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.transaction.jbosscache;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.ExoResource;
+import org.exoplatform.services.transaction.TransactionService;
+import org.jboss.cache.transaction.TransactionManagerLookup;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * @author <a href="mailto:dmitry.kataev at exoplatform.com">Dmytro Katayev</a>
+ * @version $Id: GenericTransactionService.java -1   $
+ */
+public class GenericTransactionService implements TransactionService
+{
+   /**
+    * The logger 
+    */
+   private final Log log = ExoLogger.getLogger(GenericTransactionService.class);
+   
+   /**
+    * The default timeout value of a transaction set to 20s
+    */
+   private static final int DEFAULT_TIME_OUT = 20;
+   
+   /**
+    * TransactionManagerLookup.
+    */
+   protected final TransactionManagerLookup tmLookup;
+   
+   /**
+    * The default timeout
+    */
+   protected final int defaultTimeout;
+   
+   /**
+    * The current Transaction Manager
+    */
+   private volatile TransactionManager tm; 
+
+   /**
+    * JBossTransactionManagerLookup  constructor.
+    *
+    * @param tmLookup TransactionManagerLookup
+    */
+   public GenericTransactionService(TransactionManagerLookup tmLookup)
+   {
+      this(tmLookup, null);
+   }
+   
+   public GenericTransactionService(TransactionManagerLookup tmLookup, InitParams params)
+   {
+      this.tmLookup = tmLookup;
+      if (params != null && params.getValueParam("timeout") != null)
+      {
+         this.defaultTimeout = Integer.parseInt(params.getValueParam("timeout").getValue());
+      }
+      else
+      {
+         this.defaultTimeout = DEFAULT_TIME_OUT;
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid createXid()
+   {
+      throw new UnsupportedOperationException("Method createXid() not supported");         
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void delistResource(ExoResource exores) throws RollbackException, SystemException
+   {
+      TransactionManager tm = getTransactionManager();
+      Transaction tx = tm.getTransaction();
+      if (tx != null)
+      {
+         tx.delistResource(exores.getXAResource(), XAResource.TMNOFLAGS);
+      }
+      else
+      {
+         delistResource(tm, exores);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void enlistResource(ExoResource exores) throws RollbackException, SystemException
+   {
+      TransactionManager tm = getTransactionManager();
+      Transaction tx = tm.getTransaction();
+      if (tx != null)
+      {
+         tx.enlistResource(exores.getXAResource());         
+      }
+      else
+      {
+         enlistResourceOnTxMissing(tm, exores);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getDefaultTimeout()
+   {
+      return defaultTimeout;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public TransactionManager getTransactionManager()
+   {
+      if (tm == null)
+      {
+         synchronized (this)
+         {
+            if (tm == null)
+            {
+               TransactionManager tm;
+               try
+               {
+                  tm = tmLookup.getTransactionManager();
+               }
+               catch (Exception e)
+               {
+                  throw new RuntimeException("Transaction manager not found", e);
+               }        
+               try
+               {
+                  tm.setTransactionTimeout(defaultTimeout);
+               }
+               catch (Exception e)
+               {
+                  log.warn("Cannot set the transaction timeout", e);
+               }        
+               this.tm = tm;
+            }
+         }
+      }
+      return tm;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public UserTransaction getUserTransaction()
+   {
+      throw new UnsupportedOperationException("Method UserTransaction() not supported");
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setTransactionTimeout(int seconds) throws SystemException
+   {
+      TransactionManager tm = getTransactionManager();
+      tm.setTransactionTimeout(seconds);
+   }
+   
+   /**
+    * Allows to execute an action when we try to enlist a resource when there is no active 
+    * transaction
+    */
+   protected void enlistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+   {
+   }
+   
+   /**
+    * 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
+   {
+   }
+}

Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.transaction.jbosscache;
-
-import org.exoplatform.services.transaction.ExoResource;
-import org.exoplatform.services.transaction.TransactionService;
-import org.jboss.cache.transaction.TransactionManagerLookup;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import javax.transaction.xa.Xid;
-
-/**
- * @author <a href="mailto:dmitry.kataev at exoplatform.com">Dmytro Katayev</a>
- * @version $Id$
- */
-public class JBossTransactionService implements TransactionService
-{
-
-   /**
-    * TransactionManagerLookup.
-    */
-   final protected TransactionManagerLookup tmLookup;
-
-   /**
-    * JBossTransactionManagerLookup  constructor.
-    *
-    * @param tmLookup TransactionManagerLookup
-    */
-   public JBossTransactionService(TransactionManagerLookup tmLookup)
-   {
-      this.tmLookup = tmLookup;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public Xid createXid()
-   {
-      throw new RuntimeException("Method createXid() not supported");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void delistResource(ExoResource xares) throws RollbackException, SystemException
-   {
-      throw new RuntimeException("Method delistResource() not supported");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void enlistResource(ExoResource xares) throws RollbackException, SystemException
-   {
-      throw new RuntimeException("Method enlistResource() not supported");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public int getDefaultTimeout()
-   {
-      throw new RuntimeException("Method getDefaultTimeout() not supported");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public TransactionManager getTransactionManager()
-   {
-      try
-      {
-         return tmLookup.getTransactionManager();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Transaction manager not found");
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public UserTransaction getUserTransaction()
-   {
-      throw new RuntimeException("Method UserTransaction() not supported");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void setTransactionTimeout(int seconds) throws SystemException
-   {
-      throw new RuntimeException("Method setTransactionTimeout() not supported");
-   }
-
-}

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -120,6 +120,8 @@
       log.info("before begin");
       ut.begin();
       log.info("after begin");
+      // we need to create the session within the transaction to ensure that it will be enlisted
+      Session session = (SessionImpl)repository.login(credentials, "ws");
       session.getRootNode().addNode("txcommit");
       session.save();
       assertNotNull(session.getItem("/txcommit"));
@@ -146,6 +148,8 @@
       UserTransaction ut = txService.getUserTransaction();
 
       ut.begin();
+      // we need to create the session within the transaction to ensure that it will be enlisted
+      Session session = (SessionImpl)repository.login(credentials, "ws");
       session.getRootNode().addNode("txrollback");
       session.save();
       assertNotNull(session.getItem("/txrollback"));

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -20,6 +20,7 @@
 
 import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
 import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
+import org.exoplatform.services.transaction.TransactionService;
 
 /**
  * Created by The eXo Platform SAS.
@@ -33,8 +34,8 @@
    @Override
    public WorkspaceStorageCache getCacheImpl() throws Exception
    {
-      //JBossTransactionService transactionService =
-      //   (JBossTransactionService)container.getComponentInstanceOfType(JBossTransactionService.class);
-      return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml", null);
+      TransactionService transactionService =
+         (TransactionService)container.getComponentInstanceOfType(TransactionService.class);
+      return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml", transactionService == null ? null : transactionService.getTransactionManager());
    }
 }

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java	2010-01-13 21:34:21 UTC (rev 1382)
@@ -28,15 +28,12 @@
 import org.exoplatform.services.log.Log;
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.lock.LockType;
 
 import java.io.Serializable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.transaction.TransactionManager;
-
 /**
  * @author <a href="mailto:Sergey.Kabashnyuk at exoplatform.org">Sergey Kabashnyuk</a>
  * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -62,7 +59,6 @@
       // TODO Auto-generated method stub
       super.setUp();
       cache = createCache();
-      TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
       indexUpdateMonitor = new JbossCacheIndexUpdateMonitor(cache, new IndexerIoModeHandler(IndexerIoMode.READ_WRITE));
    }
 

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml	2010-01-13 21:34:21 UTC (rev 1382)
@@ -202,7 +202,8 @@
   </component>
    
   <component>
-    <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
+    <key>org.exoplatform.services.transaction.TransactionService</key>
+    <type>org.exoplatform.services.transaction.jbosscache.ArjunaTransactionService</type>
   </component>
   
   <!-- component>

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml	2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml	2010-01-13 21:34:21 UTC (rev 1382)
@@ -195,16 +195,16 @@
     <type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
   </component>
 
-  <!-- component>
-    <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
-    <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+  <component>
+     <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
+     <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
   </component>
    
   <component>
     <key>org.exoplatform.services.transaction.TransactionService</key>
-    <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
-  </component -->
-    
+    <type>org.exoplatform.services.transaction.jbosscache.ArjunaTransactionService</type>
+  </component>
+  
   <!-- component>
     <key>org.exoplatform.services.transaction.TransactionService</key>
     <type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
@@ -214,7 +214,7 @@
         <value>5</value>
       </value-param>
     </init-params>
-  </component -->
+  </component-->
   
   <external-component-plugins>
     <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>



More information about the exo-jcr-commits mailing list