Author: tolusha
Date: 2010-09-09 08:58:23 -0400 (Thu, 09 Sep 2010)
New Revision: 3097
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
Log:
EXOJCR-830: apply remarks
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
===================================================================
---
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2010-09-09
10:28:10 UTC (rev 3096)
+++
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2010-09-09
12:58:23 UTC (rev 3097)
@@ -23,6 +23,7 @@
import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
+import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.context.Flag;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.CacheContainer;
@@ -51,12 +52,17 @@
/**
* Parent cache.
*/
- private final Cache<Serializable, Object> parentCache;
+ private final AdvancedCache<Serializable, Object> parentCache;
private final ThreadLocal<CompressedISPNChangesBuffer> changesList = new
ThreadLocal<CompressedISPNChangesBuffer>();
private ThreadLocal<Boolean> local = new ThreadLocal<Boolean>();
+ /**
+ * Allow to perform local cache changes.
+ */
+ private final Boolean allowLocalChanges;
+
protected static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.BufferedISPNCache");
public static enum ChangesType {
@@ -72,21 +78,23 @@
protected final ChangesType changesType;
- protected final Cache<Serializable, Object> cache;
+ protected final AdvancedCache<Serializable, Object> cache;
protected final int historicalIndex;
protected final boolean localMode;
- public ChangesContainer(CacheKey key, ChangesType changesType,
Cache<Serializable, Object> cache,
- int historicalIndex, boolean localMode)
+ private final Boolean allowLocalChanges;
+
+ public ChangesContainer(CacheKey key, ChangesType changesType,
AdvancedCache<Serializable, Object> cache,
+ int historicalIndex, boolean localMode, Boolean allowLocalChanges)
{
- super();
this.key = key;
this.changesType = changesType;
this.cache = cache;
this.historicalIndex = historicalIndex;
this.localMode = localMode;
+ this.allowLocalChanges = allowLocalChanges;
}
/**
@@ -119,7 +127,7 @@
@Override
public String toString()
{
- return key.toString() + " type=" + changesType + "
historyIndex=" + historicalIndex;
+ return key.toString() + " type=" + changesType + "
historysIndex=" + historicalIndex;
}
/**
@@ -135,19 +143,18 @@
{
if (localMode)
{
-
cache.getAdvancedCache().getInvocationContextContainer().getInvocationContext().setFlags(
- Flag.CACHE_MODE_LOCAL);
- }
- else
- {
- Set<Flag> flags =
-
cache.getAdvancedCache().getInvocationContextContainer().getInvocationContext().getFlags();
-
- if (flags != null)
+ if (allowLocalChanges == null)
{
- flags.remove(Flag.CACHE_MODE_LOCAL);
-
cache.getAdvancedCache().getInvocationContextContainer().getInvocationContext().setFlags(flags);
+ CacheMode cacheMode = cache.getConfiguration().getCacheMode();
+ if (cacheMode != CacheMode.DIST_ASYNC && cacheMode !=
CacheMode.DIST_SYNC)
+ {
+ cache.withFlags(Flag.CACHE_MODE_LOCAL);
+ }
}
+ else if (allowLocalChanges)
+ {
+ cache.withFlags(Flag.CACHE_MODE_LOCAL);
+ }
}
}
@@ -161,10 +168,10 @@
{
private final Object value;
- public PutObjectContainer(CacheKey key, Object value, Cache<Serializable,
Object> cache, int historicalIndex,
- boolean local)
+ public PutObjectContainer(CacheKey key, Object value,
AdvancedCache<Serializable, Object> cache,
+ int historicalIndex, boolean local, Boolean allowLocalChanges)
{
- super(key, ChangesType.PUT, cache, historicalIndex, local);
+ super(key, ChangesType.PUT, cache, historicalIndex, local, allowLocalChanges);
this.value = value;
}
@@ -185,10 +192,10 @@
{
private final Object value;
- public AddToListContainer(CacheKey key, Object value, Cache<Serializable,
Object> cache, int historicalIndex,
- boolean local)
+ public AddToListContainer(CacheKey key, Object value,
AdvancedCache<Serializable, Object> cache,
+ int historicalIndex, boolean local, Boolean allowLocalChanges)
{
- super(key, ChangesType.PUT, cache, historicalIndex, local);
+ super(key, ChangesType.PUT, cache, historicalIndex, local, allowLocalChanges);
this.value = value;
}
@@ -196,8 +203,7 @@
public void apply()
{
// force writeLock on next read
- cache.getAdvancedCache().getInvocationContextContainer().getInvocationContext()
- .setFlags(Flag.FORCE_WRITE_LOCK);
+ cache.withFlags(Flag.FORCE_WRITE_LOCK);
Object existingObject = cache.get(key);
Set<Object> newSet = new HashSet<Object>();
@@ -231,10 +237,10 @@
{
private final Object value;
- public RemoveFromListContainer(CacheKey key, Object value, Cache<Serializable,
Object> cache,
- int historicalIndex, boolean local)
+ public RemoveFromListContainer(CacheKey key, Object value,
AdvancedCache<Serializable, Object> cache,
+ int historicalIndex, boolean local, Boolean allowLocalChanges)
{
- super(key, ChangesType.REMOVE, cache, historicalIndex, local);
+ super(key, ChangesType.REMOVE, cache, historicalIndex, local,
allowLocalChanges);
this.value = value;
}
@@ -242,11 +248,9 @@
public void apply()
{
// force writeLock on next read
- cache.getAdvancedCache().getInvocationContextContainer().getInvocationContext()
- .setFlags(Flag.FORCE_WRITE_LOCK);
+ cache.withFlags(Flag.FORCE_WRITE_LOCK);
setCacheLocalMode();
-
Object existingObject = cache.get(key);
// if found value is really set! add to it.
@@ -266,9 +270,10 @@
*/
public static class RemoveObjectContainer extends ChangesContainer
{
- public RemoveObjectContainer(CacheKey key, Cache<Serializable, Object> cache,
int historicalIndex, boolean local)
+ public RemoveObjectContainer(CacheKey key, AdvancedCache<Serializable,
Object> cache, int historicalIndex,
+ boolean local, Boolean allowLocalChanges)
{
- super(key, ChangesType.REMOVE, cache, historicalIndex, local);
+ super(key, ChangesType.REMOVE, cache, historicalIndex, local,
allowLocalChanges);
}
@Override
@@ -279,16 +284,15 @@
}
}
- public BufferedISPNCache(Cache<Serializable, Object> parentCache)
+ public BufferedISPNCache(Cache<Serializable, Object> parentCache, Boolean
allowLocalChanges)
{
- super();
- this.parentCache = parentCache;
+ this.parentCache = parentCache.getAdvancedCache();
+ this.allowLocalChanges = allowLocalChanges;
}
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Void> clearAsync()
{
return parentCache.clearAsync();
@@ -297,7 +301,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void compact()
{
parentCache.compact();
@@ -306,7 +309,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void endBatch(boolean successful)
{
parentCache.endBatch(successful);
@@ -315,7 +317,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Set<java.util.Map.Entry<Serializable, Object>> entrySet()
{
return parentCache.entrySet();
@@ -324,7 +325,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void evict(Serializable key)
{
parentCache.evict(key);
@@ -333,7 +333,6 @@
/**
* {@inheritDoc}
*/
- @Override
public AdvancedCache<Serializable, Object> getAdvancedCache()
{
return parentCache.getAdvancedCache();
@@ -342,7 +341,6 @@
/**
* {@inheritDoc}
*/
- @Override
public CacheContainer getCacheManager()
{
return parentCache.getCacheManager();
@@ -351,7 +349,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Configuration getConfiguration()
{
return parentCache.getConfiguration();
@@ -360,7 +357,6 @@
/**
* {@inheritDoc}
*/
- @Override
public String getName()
{
return parentCache.getName();
@@ -369,7 +365,6 @@
/**
* {@inheritDoc}
*/
- @Override
public ComponentStatus getStatus()
{
return parentCache.getStatus();
@@ -378,7 +373,6 @@
/**
* {@inheritDoc}
*/
- @Override
public String getVersion()
{
return parentCache.getVersion();
@@ -387,7 +381,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Set<Serializable> keySet()
{
return parentCache.keySet();
@@ -396,7 +389,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object put(Serializable key, Object value, long lifespan, TimeUnit unit)
{
return parentCache.put(key, value, lifespan, unit);
@@ -405,7 +397,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object put(Serializable key, Object value, long lifespan, TimeUnit
lifespanUnit, long maxIdleTime,
TimeUnit maxIdleTimeUnit)
{
@@ -415,7 +406,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void putAll(Map<? extends Serializable, ? extends Object> map, long
lifespan, TimeUnit unit)
{
parentCache.putAll(map, lifespan, unit);
@@ -424,7 +414,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void putAll(Map<? extends Serializable, ? extends Object> map, long
lifespan, TimeUnit lifespanUnit,
long maxIdleTime, TimeUnit maxIdleTimeUnit)
{
@@ -434,7 +423,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Void> putAllAsync(Map<? extends Serializable, ?
extends Object> data)
{
return parentCache.putAllAsync(data);
@@ -443,7 +431,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Void> putAllAsync(Map<? extends Serializable, ?
extends Object> data, long lifespan,
TimeUnit unit)
{
@@ -453,7 +440,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Void> putAllAsync(Map<? extends Serializable, ?
extends Object> data, long lifespan,
TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
{
@@ -463,7 +449,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putAsync(Serializable key, Object value)
{
return parentCache.putAsync(key, value);
@@ -472,7 +457,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putAsync(Serializable key, Object value, long
lifespan, TimeUnit unit)
{
return parentCache.putAsync(key, value, lifespan, unit);
@@ -481,7 +465,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putAsync(Serializable key, Object value, long
lifespan, TimeUnit lifespanUnit,
long maxIdle, TimeUnit maxIdleUnit)
{
@@ -491,7 +474,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void putForExternalRead(Serializable key, Object value)
{
parentCache.putForExternalRead(key, value);
@@ -500,7 +482,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object putIfAbsent(Serializable key, Object value, long lifespan, TimeUnit
unit)
{
return parentCache.putIfAbsent(key, value, lifespan, unit);
@@ -509,7 +490,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object putIfAbsent(Serializable key, Object value, long lifespan, TimeUnit
lifespanUnit, long maxIdleTime,
TimeUnit maxIdleTimeUnit)
{
@@ -519,7 +499,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putIfAbsentAsync(Serializable key, Object value)
{
return parentCache.putIfAbsentAsync(key, value);
@@ -528,7 +507,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putIfAbsentAsync(Serializable key, Object value,
long lifespan, TimeUnit unit)
{
return parentCache.putIfAbsentAsync(key, value, lifespan, unit);
@@ -537,7 +515,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> putIfAbsentAsync(Serializable key, Object value,
long lifespan,
TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
{
@@ -547,7 +524,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> removeAsync(Object key)
{
return parentCache.removeAsync(key);
@@ -556,7 +532,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Boolean> removeAsync(Object key, Object value)
{
return parentCache.removeAsync(key, value);
@@ -565,7 +540,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object replace(Serializable key, Object value, long lifespan, TimeUnit unit)
{
return parentCache.replace(key, value, lifespan, unit);
@@ -574,7 +548,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean replace(Serializable key, Object oldValue, Object value, long lifespan,
TimeUnit unit)
{
return parentCache.replace(key, oldValue, value, lifespan, unit);
@@ -583,7 +556,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object replace(Serializable key, Object value, long lifespan, TimeUnit
lifespanUnit, long maxIdleTime,
TimeUnit maxIdleTimeUnit)
{
@@ -593,7 +565,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean replace(Serializable key, Object oldValue, Object value, long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime, TimeUnit maxIdleTimeUnit)
{
@@ -603,7 +574,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> replaceAsync(Serializable key, Object value)
{
return parentCache.replaceAsync(key, value);
@@ -612,7 +582,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Boolean> replaceAsync(Serializable key, Object oldValue,
Object newValue)
{
return parentCache.replaceAsync(key, oldValue, newValue);
@@ -621,7 +590,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> replaceAsync(Serializable key, Object value, long
lifespan, TimeUnit unit)
{
return parentCache.replaceAsync(key, value, lifespan, unit);
@@ -630,7 +598,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Boolean> replaceAsync(Serializable key, Object oldValue,
Object newValue, long lifespan,
TimeUnit unit)
{
@@ -640,7 +607,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Object> replaceAsync(Serializable key, Object value, long
lifespan, TimeUnit lifespanUnit,
long maxIdle, TimeUnit maxIdleUnit)
{
@@ -650,7 +616,6 @@
/**
* {@inheritDoc}
*/
- @Override
public NotifyingFuture<Boolean> replaceAsync(Serializable key, Object oldValue,
Object newValue, long lifespan,
TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
{
@@ -660,7 +625,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean startBatch()
{
return parentCache.startBatch();
@@ -669,7 +633,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Collection<Object> values()
{
return parentCache.values();
@@ -678,7 +641,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object putIfAbsent(Serializable key, Object value)
{
return parentCache.putIfAbsent(key, value);
@@ -687,7 +649,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean remove(Object key, Object value)
{
return parentCache.remove(key, value);
@@ -696,7 +657,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object replace(Serializable key, Object value)
{
return parentCache.replace(key, value);
@@ -705,7 +665,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean replace(Serializable key, Object oldValue, Object newValue)
{
return parentCache.replace(key, oldValue, newValue);
@@ -714,7 +673,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void clear()
{
parentCache.clear();
@@ -723,7 +681,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean containsKey(Object key)
{
return parentCache.containsKey(key);
@@ -732,7 +689,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean containsValue(Object value)
{
return parentCache.containsValue(value);
@@ -741,7 +697,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object get(Object key)
{
return parentCache.get(key);
@@ -750,7 +705,6 @@
/**
* {@inheritDoc}
*/
- @Override
public boolean isEmpty()
{
return parentCache.isEmpty();
@@ -766,7 +720,7 @@
{
CompressedISPNChangesBuffer changesContainer = getChangesBufferSafe();
changesContainer.add(new PutObjectContainer(key, value, parentCache,
changesContainer.getHistoryIndex(), local
- .get()));
+ .get(), allowLocalChanges));
return parentCache.get(key);
}
@@ -774,7 +728,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Object put(Serializable key, Object value)
{
throw new UnsupportedOperationException("Unexpected method call use
put(CacheKey key, Object value)");
@@ -783,7 +736,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void putAll(Map<? extends Serializable, ? extends Object> m)
{
parentCache.putAll(m);
@@ -792,19 +744,17 @@
/**
* {@inheritDoc}
*/
- @Override
public Object remove(Object key)
{
CompressedISPNChangesBuffer changesContainer = getChangesBufferSafe();
changesContainer.add(new RemoveObjectContainer((CacheKey)key, parentCache,
changesContainer.getHistoryIndex(),
- local.get()));
+ local.get(), allowLocalChanges));
return parentCache.get(key);
}
/**
* {@inheritDoc}
*/
- @Override
public int size()
{
return parentCache.size();
@@ -813,7 +763,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void start()
{
PrivilegedAction<Object> action = new PrivilegedAction<Object>()
@@ -830,7 +779,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void stop()
{
PrivilegedAction<Object> action = new PrivilegedAction<Object>()
@@ -847,7 +795,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void addListener(Object listener)
{
parentCache.addListener(listener);
@@ -856,7 +803,6 @@
/**
* {@inheritDoc}
*/
- @Override
public Set<Object> getListeners()
{
return parentCache.getListeners();
@@ -865,7 +811,6 @@
/**
* {@inheritDoc}
*/
- @Override
public void removeListener(Object listener)
{
parentCache.removeListener(listener);
@@ -961,7 +906,7 @@
{
CompressedISPNChangesBuffer changesContainer = getChangesBufferSafe();
changesContainer.add(new AddToListContainer(key, value, parentCache,
changesContainer.getHistoryIndex(), local
- .get()));
+ .get(), allowLocalChanges));
}
/**
@@ -978,7 +923,7 @@
Object prevObject = getObjectFromChangesContainer(changesContainer, key);
changesContainer.add(new PutObjectContainer(key, value, parentCache,
changesContainer.getHistoryIndex(), local
- .get()));
+ .get(), allowLocalChanges));
if (prevObject != null)
{
@@ -1015,7 +960,7 @@
{
CompressedISPNChangesBuffer changesContainer = getChangesBufferSafe();
changesContainer.add(new RemoveFromListContainer(key, value, parentCache,
changesContainer.getHistoryIndex(),
- local.get()));
+ local.get(), allowLocalChanges));
}
public Object getFromBuffer(CacheKey key)
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
---
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2010-09-09
10:28:10 UTC (rev 3096)
+++
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2010-09-09
12:58:23 UTC (rev 3097)
@@ -20,6 +20,7 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.config.CacheEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.dataflow.ItemState;
@@ -38,7 +39,6 @@
import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import org.exoplatform.services.transaction.TransactionService;
import org.infinispan.Cache;
import java.io.Serializable;
@@ -68,7 +68,7 @@
* Current state notes (subject of change):
* <ul>
* <li>cache implements WorkspaceStorageCache, without any stuff about references
and locks</li>
- * <li>transaction style implemented via JBC barches, do with JTA (i.e. via
exo's TransactionService + JBoss TM)</li>
+ * <li>transaction style implemented via batches, do with JTA (i.e. via exo's
TransactionService + JBoss TM)</li>
* </ul>
*
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
@@ -79,8 +79,6 @@
private static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.ISPNCacheWorkspaceStorageCache");
- public static final String JBOSSCACHE_CONFIG = "infinispan-configuration";
-
protected final BufferedISPNCache cache;
/**
@@ -195,12 +193,11 @@
* Cache constructor with eXo TransactionService support.
*
* @param wsConfig WorkspaceEntry workspace config
- * @param transactionService TransactionService external transaction service
* @throws RepositoryException if error of initialization
* @throws RepositoryConfigurationException if error of configuration
*/
- public ISPNCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, TransactionService
transactionService,
- ConfigurationManager cfm) throws RepositoryException,
RepositoryConfigurationException
+ public ISPNCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager
cfm) throws RepositoryException,
+ RepositoryConfigurationException
{
if (wsConfig.getCache() == null)
{
@@ -210,26 +207,23 @@
// create cache using custom factory
ISPNCacheFactory<Serializable, Object> factory = new
ISPNCacheFactory<Serializable, Object>(cfm);
- // create parent JBossCache instance
- Cache<Serializable, Object> parentCache =
factory.createCache(wsConfig.getCache());
+ // create parent Infinispan instance
+ CacheEntry cacheEntry = wsConfig.getCache();
+ Cache<Serializable, Object> parentCache = factory.createCache(cacheEntry);
- this.cache = new BufferedISPNCache(parentCache);
+ Boolean allowLocalChanges = null;
+ try
+ {
+ allowLocalChanges =
cacheEntry.getParameterBoolean("allow-local-changes");
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ // do n't nothing
+ }
+ this.cache = new BufferedISPNCache(parentCache, allowLocalChanges);
}
/**
- * Cache constructor with JBossCache JTA transaction support.
- *
- * @param wsConfig WorkspaceEntry workspace config
- * @throws RepositoryException if error of initialization
- * @throws RepositoryConfigurationException if error of configuration
- */
- public ISPNCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager
cfm) throws RepositoryException,
- RepositoryConfigurationException
- {
- this(wsConfig, null, cfm);
- }
-
- /**
* {@inheritDoc}
*/
public void put(ItemData item)
@@ -431,7 +425,8 @@
*/
public ItemData get(String parentId, QPathEntry name)
{
- return (ItemData)cache.get(new CacheQPath(parentId, name));
+ String id = (String)cache.get(new CacheQPath(parentId, name));
+ return get(id);
}
/**
@@ -603,7 +598,7 @@
}
}
- cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath()), node);
+ cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath()),
node.getIdentifier());
return (ItemData)cache.put(new CacheId(node.getIdentifier()), node);
}
@@ -619,7 +614,7 @@
}
}
- cache.putInBuffer(new CacheQPath(node.getParentIdentifier(), node.getQPath()),
node);
+ cache.putInBuffer(new CacheQPath(node.getParentIdentifier(), node.getQPath()),
node.getIdentifier());
return (ItemData)cache.putInBuffer(new CacheId(node.getIdentifier()), node);
}
@@ -638,7 +633,7 @@
cache.addToList(new CachePropsId(prop.getParentIdentifier()),
prop.getIdentifier());
}
- cache.put(new CacheQPath(prop.getParentIdentifier(), prop.getQPath()), prop);
+ cache.put(new CacheQPath(prop.getParentIdentifier(), prop.getQPath()),
prop.getIdentifier());
return (PropertyData)cache.put(new CacheId(prop.getIdentifier()), prop);
}
@@ -646,6 +641,8 @@
{
cache.remove(new CacheId(item.getIdentifier()));
cache.remove(new CacheQPath(item.getParentIdentifier(), item.getQPath()));
+ cache.remove(new CacheNodesId(item.getIdentifier()));
+ cache.remove(new CachePropsId(item.getIdentifier()));
if (item.getParentIdentifier() != null)
{
@@ -668,7 +665,7 @@
protected void updateMixin(NodeData node)
{
NodeData prevData = (NodeData)cache.put(new CacheId(node.getIdentifier()), node);
- cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath()), node);
+ cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath()),
node.getIdentifier());
if (prevData != null)
{
@@ -730,7 +727,7 @@
while (keys.hasNext())
{
CacheKey key = (CacheKey)keys.next();
- if (key instanceof CacheId || key instanceof CacheQPath)
+ if (key instanceof CacheId)
{
ItemData data = (ItemData)cache.get(key);
@@ -766,14 +763,7 @@
prevNode.getParentIdentifier(), inheritACL ? acl :
prevNode.getACL());
// update this node
- if (key instanceof CacheId)
- {
- cache.put(new CacheId(newNode.getIdentifier()), newNode);
- }
- else
- {
- cache.put(new CacheQPath(newNode.getParentIdentifier(),
newNode.getQPath()), newNode);
- }
+ cache.put(new CacheId(newNode.getIdentifier()), newNode);
}
else
{
@@ -793,14 +783,7 @@
.getValues());
// update this property
- if (key instanceof CacheId)
- {
- cache.put(new CacheId(newProp.getIdentifier()), newProp);
- }
- else
- {
- cache.put(new CacheQPath(newProp.getParentIdentifier(),
newProp.getQPath()), newProp);
- }
+ cache.put(new CacheId(newProp.getIdentifier()), newProp);
}
}
}
@@ -837,7 +820,6 @@
// update this node
cache.put(new CacheId(newNode.getIdentifier()), newNode);
- cache.put(new CacheQPath(newNode.getIdentifier(), newNode.getQPath()),
newNode);
// update childs recursive
updateChildsACL(newNode.getIdentifier(), acl);