// create cache using custom factory
ISPNCacheFactory<CacheKey, Object> factory =
new ISPNCacheFactory<CacheKey, Object>(cfm, ts == null ? null : ts.getTransactionManager());
// create parent Infinispan instance
CacheEntry cacheEntry = wsConfig.getCache();
boolean useDistributedCache = cacheEntry.getParameterBoolean("use-distributed-cache", false);
Cache<CacheKey, Object> parentCache;
if (useDistributedCache)
{
// We expect a distributed cache
if (dcm == null)
{
throw new IllegalArgumentException("The DistributedCacheManager has not been defined in the configuration,"
+ " please configure it at root container level if you want to use a distributed cache.");
}
parentCache = dcm.getCache(CACHE_NAME);
this.ownerId = ctx.getName();
if (LOG.isDebugEnabled())
{
LOG.debug("The distributed cache has been enabled for the workspace whose unique id is " + ownerId);
}
}
else
{
parentCache = factory.createCache("Data_" + wsConfig.getUniqueName(), cacheEntry);
Configuration config = parentCache.getCacheConfiguration();
if (config.clustering().cacheMode() == CacheMode.DIST_SYNC
|| config.clustering().cacheMode() == CacheMode.DIST_ASYNC)
{
throw new IllegalArgumentException("Cache configuration not allowed, if you want to use the distributed "
+ "cache please enable the parameter 'use-distributed-cache' and configure the DistributedCacheManager.");
}
this.ownerId = null;
}
Boolean allowLocalChanges =
useDistributedCache ? cacheEntry.getParameterBoolean("allow-local-changes", Boolean.TRUE) : Boolean.TRUE;
this.cache = new BufferedISPNCache(parentCache, allowLocalChanges);
if (useDistributedCache)
{
this.caller = new DistributedOperationCaller();
}