Author: dkuleshov
Date: 2010-10-21 08:27:21 -0400 (Thu, 21 Oct 2010)
New Revision: 3311
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-965: fixed feature in case cache is disabled at the beginning and enabled later
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-10-21
12:19:25 UTC (rev 3310)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-10-21
12:27:21 UTC (rev 3311)
@@ -27,6 +27,7 @@
import javax.transaction.TransactionManager;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import
org.exoplatform.services.jcr.dataflow.persistent.MandatoryItemsPersistenceListener;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
@@ -275,6 +276,32 @@
}
/**
+ * This class is a decorator on the top of the {@link WorkspaceStorageCache} to manage
the case
+ * where the cache is disabled at the beginning then potentially enabled later
+ */
+ private class CacheItemsPersistenceListener implements
MandatoryItemsPersistenceListener
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return cache.isTXAware();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+ if (cache.isEnabled())
+ {
+ cache.onSaveItems(itemStates);
+ }
+ }
+ }
+
+ /**
* CacheableWorkspaceDataManager constructor.
*
* @param dataContainer
@@ -292,7 +319,7 @@
this.cache = cache;
this.requestCache = new ConcurrentHashMap<Integer, DataRequest>();
- addItemPersistenceListener(cache);
+ addItemPersistenceListener(new CacheItemsPersistenceListener());
transactionManager = transactionService.getTransactionManager();
}
@@ -314,7 +341,7 @@
this.cache = cache;
this.requestCache = new ConcurrentHashMap<Integer, DataRequest>();
- addItemPersistenceListener(cache);
+ addItemPersistenceListener(new CacheItemsPersistenceListener());
if (cache instanceof JBossCacheWorkspaceStorageCache)
{
@@ -542,7 +569,7 @@
protected ItemData getCachedItemData(NodeData parentData, QPathEntry name, ItemType
itemType)
throws RepositoryException
{
- return cache.get(parentData.getIdentifier(), name, itemType);
+ return cache.isEnabled() ? cache.get(parentData.getIdentifier(), name, itemType) :
null;
}
/**
@@ -556,7 +583,7 @@
*/
protected ItemData getCachedItemData(String identifier) throws RepositoryException
{
- return cache.get(identifier);
+ return cache.isEnabled() ? cache.get(identifier) : null;
}
/**
Show replies by date