// Avoid potential naming collision by changing the cluster name
cache.getConfiguration().setClusterName(
cache.getConfiguration().getClusterName() + rootFqn.toString().replace('/', '-'));
return cache;
}
ExoContainer container = ExoContainerContext.getCurrentContainer();
Map<CacheType, Map<ConfigurationKey, CacheInstance>> allCacheTypes = CACHES.get(container);
if (allCacheTypes == null)
{
allCacheTypes = new HashMap<CacheType, Map<ConfigurationKey, CacheInstance>>();
CACHES.put(container, allCacheTypes);
}
Map<ConfigurationKey, CacheInstance> caches = allCacheTypes.get(cacheType);
if (caches == null)
{
caches = new HashMap<ConfigurationKey, CacheInstance>();
allCacheTypes.put(cacheType, caches);
}
Configuration cfg = cache.getConfiguration();
ConfigurationKey key;
try
{
key = new ConfigurationKey(cfg);
}
catch (CloneNotSupportedException e)
{
throw new RepositoryConfigurationException("Cannot clone the configuration.", e);
}
if (caches.containsKey(key))
{
CacheInstance cacheInstance = caches.get(key);
cacheInstance.acquire();
cache = cacheInstance.cache;
}
else
{
CacheInstance cacheInstance = new CacheInstance(cache);
cacheInstance.acquire();
caches.put(key, cacheInstance);
if (LOG.isInfoEnabled())
{
LOG.info("A new JBoss Cache instance has been registered for the region " + rootFqn + ", a cache of type "
+ cacheType + " and the container " + container.getContext().getName());
}
}
addEvictionRegion(rootFqn, cache, cfg);
if (LOG.isInfoEnabled())
{
LOG.info("The region " + rootFqn + " has been registered for a cache of type " + cacheType
+ " and the container " + container.getContext().getName());
}
return cache;
}