List of usage examples for org.hibernate.cache.spi SecondLevelCacheLogger INSTANCE
SecondLevelCacheLogger INSTANCE
To view the source code for org.hibernate.cache.spi SecondLevelCacheLogger INSTANCE.
Click Source Link
From source file:org.infinispan.hibernate.cache.v53.InfinispanRegionFactory.java
License:LGPL
protected AdvancedCache getCache(String cacheName, String unqualifiedRegionName, DataType type, Collection<String> legacyUnqualifiedNames) { if (!manager.cacheExists(cacheName)) { String templateCacheName = baseConfigurations.get(cacheName); Configuration configuration; ConfigurationBuilder builder = new ConfigurationBuilder(); if (templateCacheName == null) { templateCacheName = baseConfigurations.get(unqualifiedRegionName); if (templateCacheName != null) { log.usingUnqualifiedNameInConfiguration(unqualifiedRegionName, cacheName); }/* w w w .j a v a 2 s . c om*/ } if (templateCacheName != null) { configuration = manager.getCacheConfiguration(templateCacheName); if (configuration == null) { log.customConfigForRegionNotFound(templateCacheName, cacheName, type.key); } else { log.debugf("Region '%s' will use cache template '%s'", cacheName, templateCacheName); builder.read(configuration); unsetTransactions(builder); // do not apply data type overrides to regions that set special cache configuration if (templateCacheName.equals(cacheName)) { // we'll define the configuration at the end of this method manager.undefineConfiguration(cacheName); } } } else { configuration = manager.getCacheConfiguration(cacheName); if (configuration != null) { // While we could just use the defined configuration it's better to force user to include // the configuration properties so that it's obvious from persistence.xml that this entity // will get some special treatment. log.regionNameMatchesCacheName(cacheName, cacheName, cacheName); manager.undefineConfiguration(cacheName); } if (manager.getCacheConfiguration(unqualifiedRegionName) != null) { log.configurationWithUnqualifiedName(unqualifiedRegionName, cacheName); } } // Before the very default configuration for the type try legacy configuration names for (String legacyUnqualified : legacyUnqualifiedNames) { configuration = manager.getCacheConfiguration(qualify(legacyUnqualified)); if (configuration != null) { SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName(cacheName, qualify(legacyUnqualified)); break; } configuration = manager.getCacheConfiguration(legacyUnqualified); if (configuration != null) { SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName(cacheName, legacyUnqualified); break; } } if (configuration == null) { configuration = dataTypeConfigurations.get(type); if (configuration == null) { throw new IllegalStateException("Configuration not defined for type " + type.key); } builder.read(configuration); // overrides for data types are already applied, but we should check custom ones } ConfigurationBuilder override = configOverrides.get(cacheName); if (override != null) { log.debugf("Region '%s' has additional configuration set through properties.", cacheName); builder.read(override.build(false)); } if (globalStats != null) { builder.jmxStatistics().enabled(globalStats).available(globalStats); } configuration = builder.build(); type.validate(configuration); manager.defineConfiguration(cacheName, configuration); } final AdvancedCache cache = manager.getCache(cacheName).getAdvancedCache(); // TODO: not sure if this is needed in recent Infinispan if (!cache.getStatus().allowInvocations()) { cache.start(); } return cache; }