/**
* initialises the CacheManager
*/
protected void init(Configuration initialConfiguration, String configurationFileName, URL configurationURL,
InputStream configurationInputStream) {
Configuration localConfiguration = initialConfiguration;
if (initialConfiguration == null) {
localConfiguration = parseConfiguration(configurationFileName, configurationURL, configurationInputStream);
this.configuration = localConfiguration;
} else {
this.configuration = initialConfiguration;
}
if (this.configuration.getTerracottaConfiguration() != null) {
this.configuration.getTerracottaConfiguration().freezeConfig();
}
validateConfiguration();
if (localConfiguration.getName() != null) {
this.name = localConfiguration.getName();
}
this.allowsDynamicCacheConfig = localConfiguration.getDynamicConfig();
this.terracottaClientConfiguration = localConfiguration.getTerracottaConfiguration();
terracottaClient = new TerracottaClient(this, new TerracottaClientRejoinListener() {
public void clusterRejoinStarted() {
CacheManager.this.clusterRejoinStarted();
}
public void clusterRejoinComplete() {
CacheManager.this.clusterRejoinComplete();
}
}, localConfiguration.getTerracottaConfiguration());
Map<String, CacheConfiguration> cacheConfigs = localConfiguration.getCacheConfigurations();
if (localConfiguration.getDefaultCacheConfiguration() != null
&& localConfiguration.getDefaultCacheConfiguration().isTerracottaClustered()) {
terracottaClient.createClusteredInstanceFactory(cacheConfigs);
} else {
for (CacheConfiguration config : cacheConfigs.values()) {
if (config.isTerracottaClustered()) {
terracottaClient.createClusteredInstanceFactory(cacheConfigs);
break;
}
}
}
if (terracottaClient.getClusteredInstanceFactory() != null && this.name == null) {
this.name = CacheManager.DEFAULT_NAME;
}
TransactionIDFactory transactionIDFactory = createTransactionIDFactory();
this.transactionController = new TransactionController(transactionIDFactory, configuration.getDefaultTransactionTimeoutInSeconds());
ConfigurationHelper configurationHelper = new ConfigurationHelper(this, localConfiguration);
configure(configurationHelper);
status = Status.STATUS_ALIVE;
for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) {
cacheManagerPeerProvider.init();
}
cacheManagerEventListenerRegistry.init();
addShutdownHookIfRequired();
cacheManagerTimer = new FailSafeTimer(getName());
checkForUpdateIfNeeded(localConfiguration.getUpdateCheck());
mbeanRegistrationProvider = MBEAN_REGISTRATION_PROVIDER_FACTORY.createMBeanRegistrationProvider(localConfiguration);
// do this last
addConfiguredCaches(configurationHelper);