private <K, V> Cache<K, V> getCache(String cacheName, Configuration config)
{
ContextClassLoaderSwitcher.SwitchContext context = this.switcher.getSwitchContext(this.getClass().getClassLoader());
try
{
if (config.getCacheMode().isDistributed())
{
GlobalConfiguration globalConfig = this.container.getGlobalConfiguration();
String containerName = this.appendCacheName(globalConfig.getCacheManagerName(), cacheName);
EmbeddedCacheManager container = this.containers.get(containerName);
if (container == null)
{
GlobalConfiguration global = globalConfig.clone();
global.setCacheManagerName(containerName);
global.setClusterName(this.appendCacheName(globalConfig.getClusterName(), cacheName));
global.getTransportProperties().setProperty(DefaultCacheContainerFactory.CHANNEL_ID, global.getClusterName());
container = new SingletonCacheManager(this, cacheName, global, config);
EmbeddedCacheManager existing = this.containers.putIfAbsent(containerName, container);