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

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 19 07:24:19 EST 2010


Author: skabashnyuk
Date: 2010-01-19 07:24:19 -0500 (Tue, 19 Jan 2010)
New Revision: 1478

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
Log:
EXOJCR-390 : cache.beginTransaction() is colled in JBossCache

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-19 12:18:31 UTC (rev 1477)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-01-19 12:24:19 UTC (rev 1478)
@@ -191,7 +191,9 @@
       {
          DataRequest prev = requestCache.get(this.hashCode());
          if (prev != null)
+         {
             prev.await();
+         }
          return this;
       }
 
@@ -248,6 +250,7 @@
       }
    }
 
+   @Deprecated
    protected abstract class StorageTxIsolatedOperation extends TxIsolatedOperation
    {
       StorageTxIsolatedOperation()
@@ -275,12 +278,13 @@
       }
    }
 
-   protected class SaveInTransaction extends StorageTxIsolatedOperation
+   protected class SaveInTransaction extends TxIsolatedOperation
    {
       final ItemStateChangesLog changes;
 
       SaveInTransaction(ItemStateChangesLog changes)
       {
+         super(transactionManager);
          this.changes = changes;
       }
 
@@ -731,111 +735,6 @@
       return propertiesList;
    }
 
-   //   /**
-   //    * Apply all the changes in new XA transaction. This save should run in dedicated XA transaction, 
-   //    * i.e. only JCR storage stuff should be involved to.
-   //    */
-   //   private void saveInTransaction(ItemStateChangesLog changes) throws RepositoryException
-   //   {
-   //      try
-   //      {
-   //         transactionManager.begin(); // start new global tx
-   //         cache.beginTransaction(); // TODO keep it into the cache impl
-   //         CacheableWorkspaceDataManager.super.save(changes);
-   //         cache.commitTransaction();
-   //         transactionManager.commit(); // commit global tx
-   //      }
-   //      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(); // rollback global tx
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
-   //      }
-   //      catch (InvalidItemStateException e)
-   //      {
-   //         try
-   //         {
-   //            cache.rollbackTransaction();
-   //            transactionManager.rollback();
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new InvalidItemStateException(e);
-   //      }
-   //      catch (ItemExistsException e)
-   //      {
-   //         try
-   //         {
-   //            cache.rollbackTransaction();
-   //            transactionManager.rollback();
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new ItemExistsException(e);
-   //      }
-   //      catch (ReadOnlyWorkspaceException e)
-   //      {
-   //         try
-   //         {
-   //            cache.rollbackTransaction();
-   //            transactionManager.rollback();
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new ReadOnlyWorkspaceException(e);
-   //      }
-   //      catch (RepositoryException e)
-   //      {
-   //         try
-   //         {
-   //            cache.rollbackTransaction();
-   //            transactionManager.rollback();
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new RepositoryException(e);
-   //      }
-   //      catch (Exception e)
-   //      {
-   //         try
-   //         {
-   //            cache.rollbackTransaction();
-   //            transactionManager.rollback();
-   //         }
-   //         catch (Exception e1)
-   //         {
-   //            LOG.error("Rollback error ", e1);
-   //         }
-   //
-   //         throw new RepositoryException(e);
-   //      }
-   //   }
-
    protected boolean isTxAware()
    {
       return transactionManager != null;

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-19 12:18:31 UTC (rev 1477)
+++ 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-19 12:24:19 UTC (rev 1478)
@@ -392,43 +392,58 @@
     */
    public void onSaveItems(final ItemStateChangesLog itemStates)
    {
-      for (ItemState state : itemStates.getAllStates())
+      //  if something happen we will rollback changes
+      boolean rollback = true;
+      try
       {
-         if (state.isAdded())
+         cache.beginTransaction();
+         for (ItemState state : itemStates.getAllStates())
          {
-            if (state.isPersisted())
+            if (state.isAdded())
             {
+               if (state.isPersisted())
+               {
+                  putItem(state.getData());
+               }
+            }
+            else if (state.isUpdated())
+            {
+               if (state.isPersisted())
+               {
+                  ItemData prevItem = putItem(state.getData());
+                  if (prevItem != null && state.isNode())
+                  {
+                     // nodes reordered, if prev is null it's InvalidItemState case
+                     update((NodeData)state.getData(), (NodeData)prevItem);
+                  }
+               }
+            }
+            else if (state.isDeleted())
+            {
+               removeItem(state.getData());
+            }
+            else if (state.isRenamed())
+            {
                putItem(state.getData());
             }
-         }
-         else if (state.isUpdated())
-         {
-            if (state.isPersisted())
+            else if (state.isMixinChanged())
             {
-               ItemData prevItem = putItem(state.getData());
-               if (prevItem != null && state.isNode())
+               if (state.isPersisted())
                {
-                  // nodes reordered, if prev is null it's InvalidItemState case
-                  update((NodeData)state.getData(), (NodeData)prevItem);
+                  // update subtree ACLs
+                  updateMixin((NodeData)state.getData());
                }
             }
          }
-         else if (state.isDeleted())
+         cache.commitTransaction();
+         rollback = false;
+      }
+      finally
+      {
+         if (rollback)
          {
-            removeItem(state.getData());
+            cache.rollbackTransaction();
          }
-         else if (state.isRenamed())
-         {
-            putItem(state.getData());
-         }
-         else if (state.isMixinChanged())
-         {
-            if (state.isPersisted())
-            {
-               // update subtree ACLs
-               updateMixin((NodeData)state.getData());
-            }
-         }
       }
    }
 



More information about the exo-jcr-commits mailing list