// The cache is not shareable
// 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, Cache>> allCacheTypes = CACHES.get(container);
if (allCacheTypes == null)
{
allCacheTypes = new HashMap<CacheType, Map<ConfigurationKey, Cache>>();
CACHES.put(container, allCacheTypes);
}
Map<ConfigurationKey, Cache> caches = allCacheTypes.get(cacheType);
if (caches == null)
{
caches = new HashMap<ConfigurationKey, Cache>();
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))
{
cache = caches.get(key);
}
else
{
caches.put(key, cache);
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;
}