// Read the configuration file of the cache
is = configManager.getInputStream(cacheConfigTemplate);
}
catch (Exception e)//NOSONAR
{
throw new ExoCacheInitException("The configuration of the CacheManager cannot be loaded from '"
+ cacheConfigTemplate + "'", e);
}
if (is == null)
{
throw new ExoCacheInitException("The configuration of the CacheManager cannot be found at '"
+ cacheConfigTemplate + "'");
}
GlobalConfigurationBuilder configBuilder;
Configuration config;
try
{
ParserRegistry parser = new ParserRegistry(Thread.currentThread().getContextClassLoader());
// Loads the configuration from the input stream
ConfigurationBuilderHolder holder = parser.parse(is);
configBuilder = holder.getGlobalConfigurationBuilder();
config = holder.getDefaultConfigurationBuilder().build();
}
catch (RuntimeException e) //NOSONAR
{
throw new ExoCacheInitException("Cannot parse the configuration '" + cacheConfigTemplate + "'", e);
}
configureCacheManager(configBuilder);
DefaultCacheManager cacheManager;
try
{
// Create the CacheManager from the new configuration
cacheManager = new DefaultCacheManager(configBuilder.build(), config);
}
catch (RuntimeException e) //NOSONAR
{
throw new ExoCacheInitException(
"Cannot initialize the CacheManager corresponding to the configuration '" + cacheConfigTemplate
+ "'", e);
}
// Register the main cache manager
mappingGlobalConfigCacheManager.put(cacheManager.getCacheManagerConfiguration().transport().clusterName(),
cacheManager);
return cacheManager;
}
});
}
catch (PrivilegedActionException e)
{
Throwable cause = e.getCause();
if (cause instanceof ExoCacheInitException)
{
throw (ExoCacheInitException)cause;//NOSONAR
}
else
{
throw new ExoCacheInitException(e);
}
}
}