Author: nfilotto
Date: 2010-09-16 11:32:57 -0400 (Thu, 16 Sep 2010)
New Revision: 3125
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
Log:
EXOJCR-938: Since the cluster name will be ${original-cluster-name} + "-" +
${container-name}, we are sure that 2 caches created by 2 different ExoContainer will
never share the same CacheManager since their GlobalConfig will be different, so the Map
in which we register the CacheManager has been simplified
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
===================================================================
---
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2010-09-16
15:16:19 UTC (rev 3124)
+++
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2010-09-16
15:32:57 UTC (rev 3125)
@@ -62,8 +62,8 @@
* A Map that contains all the registered CacheManager order by {@link ExoContainer}
* instances and {@link GlobalConfiguration}.
*/
- private static Map<ExoContainer, Map<GlobalConfiguration,
EmbeddedCacheManager>> CACHES =
- new HashMap<ExoContainer, Map<GlobalConfiguration,
EmbeddedCacheManager>>();
+ private static Map<GlobalConfiguration, EmbeddedCacheManager> CACHE_MANAGERS =
+ new HashMap<GlobalConfiguration, EmbeddedCacheManager>();
/**
* Creates InfinispanCacheFactory with provided configuration transaction managers.
@@ -140,24 +140,18 @@
*/
private static synchronized EmbeddedCacheManager getUniqueInstance(String regionId,
EmbeddedCacheManager manager)
{
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- Map<GlobalConfiguration, EmbeddedCacheManager> allCacheManagers =
CACHES.get(container);
- if (allCacheManagers == null)
- {
- allCacheManagers = new HashMap<GlobalConfiguration,
EmbeddedCacheManager>();
- CACHES.put(container, allCacheManagers);
- }
GlobalConfiguration gc = manager.getGlobalConfiguration();
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
// Ensure that the cluster name won't be used between 2 ExoContainers
gc.setClusterName(gc.getClusterName() + "-" +
container.getContext().getName());
Configuration conf = manager.getDefaultConfiguration();
- if (allCacheManagers.containsKey(gc))
+ if (CACHE_MANAGERS.containsKey(gc))
{
- manager = allCacheManagers.get(gc);
+ manager = CACHE_MANAGERS.get(gc);
}
else
{
- allCacheManagers.put(gc, manager);
+ CACHE_MANAGERS.put(gc, manager);
if (log.isInfoEnabled())
log.info("A new JBoss Cache instance has been registered for the region
" + regionId + " and the container " + container.getContext().getName());
}