[exo-jcr-commits] exo-jcr SVN: r1337 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/lock and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 11 05:54:51 EST 2010
Author: sergiykarpenko
Date: 2010-01-11 05:54:50 -0500 (Mon, 11 Jan 2010)
New Revision: 1337
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/ItemsPersistenceListener.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
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/LinkedWorkspaceStorageCacheImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.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/writing/TestSetProperty.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TesterItemsPersistenceListener.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java
Log:
EXOJCR-376: listeners separated for those that notified in transaction and after that
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/ItemsPersistenceListener.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/ItemsPersistenceListener.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/ItemsPersistenceListener.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -29,9 +29,15 @@
public interface ItemsPersistenceListener
{
/**
- * Will be called wnen data is permanently saved.
+ * Will be called when data is permanently saved.
*
* @param itemStates ItemStateChangesLog
*/
void onSaveItems(ItemStateChangesLog itemStates);
+
+ /**
+ * Return true if listener must be called in transaction, false if not.
+ * @return boolean
+ */
+ boolean isTXAware();
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -799,4 +799,12 @@
{
removeExpired();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -264,4 +264,12 @@
throw new RepositoryException("Unexpected ItemState for Node " + ItemState.nameFromValue(state.getState()) + " "
+ state.getData().getQPath().getAsString());
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -246,4 +246,11 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -836,4 +836,12 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return false;
+ }
+
}
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-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -202,7 +202,8 @@
transactionManager.begin();
transactionManager.setTransactionTimeout(20);
cache.beginTransaction();
- super.save(changesLog);
+ // save changes and notify only txAware listeners
+ super.saveInTransaction(changesLog);
cache.commitTransaction();
transactionManager.commit();
}
@@ -240,6 +241,8 @@
e.printStackTrace();
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
+ // notify listeners after transaction commit
+ super.postTransactionNotify(changesLog);
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -1881,18 +1881,26 @@
public void beginTransaction()
{
// TODO Auto-generated method stub
-
+
}
public void commitTransaction()
{
// TODO Auto-generated method stub
-
+
}
public void rollbackTransaction()
{
// TODO Auto-generated method stub
-
+
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -118,6 +118,41 @@
*/
public void save(final ItemStateChangesLog changesLog) throws RepositoryException
{
+ doSave(changesLog);
+ notifySaveItems(changesLog);
+ }
+
+ /**
+ * Saves the list of changes from this storage. And notifies listeners that are transaction aware.
+ *
+ * @param changesLog
+ * @throws RepositoryException
+ */
+ public void saveInTransaction(final ItemStateChangesLog changesLog) throws RepositoryException
+ {
+ doSave(changesLog);
+ notifySaveItemsOnTransaction(changesLog, true);
+ }
+
+ /**
+ * Notifies listeners that are not transaction aware.
+ * Must be called after transaction commit.
+ *
+ * @param changesLog
+ */
+ public void postTransactionNotify(final ItemStateChangesLog changesLog)
+ {
+ notifySaveItemsOnTransaction(changesLog, false);
+ }
+
+ /**
+ * Save the list of changes to storage.
+ *
+ * @param changesLog
+ * @throws RepositoryException
+ */
+ private void doSave(final ItemStateChangesLog changesLog) throws RepositoryException
+ {
//LOG.info(changesLog.dump())
// check if this workspace container is not read-only
if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
@@ -223,8 +258,6 @@
// help to GC
addedNodes.clear();
}
-
- notifySaveItems(changesLog);
}
/**
@@ -290,7 +323,7 @@
con.close();
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -305,7 +338,7 @@
{
con.close();
}
- }
+ }
/**
* {@inheritDoc}
@@ -564,7 +597,7 @@
* @param changesLog
* ItemStateChangesLog
*/
- protected void notifySaveItems(ItemStateChangesLog changesLog)
+ protected void notifySaveItems(final ItemStateChangesLog changesLog)
{
for (MandatoryItemsPersistenceListener mlistener : mandatoryListeners)
mlistener.onSaveItems(changesLog);
@@ -577,6 +610,27 @@
}
/**
+ * Notify listeners according to isTransaction parameter and is listener transaction aware.
+ *
+ * @param changesLog - Changes log to notify listeners
+ * @param isTransaction - is listeners notified in transaction, or after transaction
+ */
+ protected void notifySaveItemsOnTransaction(final ItemStateChangesLog changesLog, boolean isTransaction)
+ {
+ for (MandatoryItemsPersistenceListener mlistener : mandatoryListeners)
+ {
+ if (mlistener.isTXAware() == isTransaction)
+ mlistener.onSaveItems(changesLog);
+ }
+
+ for (ItemsPersistenceListener listener : listeners)
+ {
+ if (listener.isTXAware() == isTransaction && isListenerAccepted(listener))
+ listener.onSaveItems(changesLog);
+ }
+ }
+
+ /**
* Tell if the path is jcr:system descendant.
*
* @param path
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-11 10:45:53 UTC (rev 1336)
+++ 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-11 10:54:50 UTC (rev 1337)
@@ -35,9 +35,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.log.ExoLogger;
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.Fqn;
import org.jboss.cache.Node;
@@ -962,19 +960,26 @@
public void beginTransaction()
{
cache.beginTransaction();
-
+
}
public void commitTransaction()
{
cache.commitTransaction();
-
+
}
public void rollbackTransaction()
{
cache.rollbackTransaction();
-
+
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -395,4 +395,12 @@
{
cLog = (TransactionChangesLog)itemStates;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -96,6 +96,11 @@
{
logsList.clear();
}
+
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
public void testSerialization() throws Exception
@@ -166,4 +171,11 @@
return data;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TesterItemsPersistenceListener.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TesterItemsPersistenceListener.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TesterItemsPersistenceListener.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -83,4 +83,12 @@
{
logsList.clear();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java 2010-01-11 10:45:53 UTC (rev 1336)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java 2010-01-11 10:54:50 UTC (rev 1337)
@@ -18,16 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.value;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.jcr.Node;
-
import org.exoplatform.services.jcr.BaseStandaloneTest;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
@@ -40,6 +30,15 @@
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
import org.exoplatform.services.jcr.impl.dataflow.serialization.TransactionChangesLogWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+
/**
* Created by The eXo Platform SAS.
*
@@ -183,24 +182,35 @@
{
cLog = (TransactionChangesLog)itemStates;
}
-
- private boolean isSpooling(String[] before, String[] after) {
- int newFilecount = 0;
-
- List<String> lBefore = new ArrayList<String>();
- for (String sBefore : before)
- lBefore.add(sBefore);
-
- for (String sAfter : after) {
- if (!lBefore.contains(sAfter)) {
- if (haveValueStorage && newFilecount == 0 || newFilecount == 0)
- newFilecount++;
- else
- return true;
+
+ private boolean isSpooling(String[] before, String[] after)
+ {
+ int newFilecount = 0;
+
+ List<String> lBefore = new ArrayList<String>();
+ for (String sBefore : before)
+ lBefore.add(sBefore);
+
+ for (String sAfter : after)
+ {
+ if (!lBefore.contains(sAfter))
+ {
+ if (haveValueStorage && newFilecount == 0 || newFilecount == 0)
+ newFilecount++;
+ else
+ return true;
+ }
+
}
-
- }
-
- return false;
+
+ return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
}
More information about the exo-jcr-commits
mailing list