use of org.cache2k.jcache.ExtendedConfiguration in project cache2k by cache2k.
the class JCacheBuilder method setConfiguration.
public void setConfiguration(Configuration<K, V> cfg) {
if (cfg instanceof CompleteConfiguration) {
config = (CompleteConfiguration<K, V>) cfg;
if (cfg instanceof ExtendedConfiguration) {
cache2kConfiguration = ((ExtendedConfiguration<K, V>) cfg).getCache2kConfiguration();
if (cache2kConfiguration != null) {
if (cache2kConfiguration.getName() != null && !cache2kConfiguration.getName().equals(name)) {
throw new IllegalArgumentException("cache name mismatch.");
}
cache2kConfigurationWasProvided = true;
}
}
} else {
MutableConfiguration<K, V> _cfgCopy = new MutableConfiguration<K, V>();
_cfgCopy.setTypes(cfg.getKeyType(), cfg.getValueType());
_cfgCopy.setStoreByValue(cfg.isStoreByValue());
config = _cfgCopy;
}
if (cache2kConfiguration == null) {
cache2kConfiguration = CacheManagerImpl.PROVIDER.getDefaultConfiguration(manager.getCache2kManager());
if (cfg instanceof ExtendedMutableConfiguration) {
((ExtendedMutableConfiguration) cfg).setCache2kConfiguration(cache2kConfiguration);
}
}
cache2kConfiguration.setName(name);
Cache2kCoreProviderImpl.augmentConfiguration(manager.getCache2kManager(), cache2kConfiguration);
cache2kConfigurationWasProvided |= cache2kConfiguration.isExternalConfigurationPresent();
if (cache2kConfigurationWasProvided) {
extraConfiguration = CACHE2K_DEFAULTS;
JCacheConfiguration _extraConfigurationSpecified = cache2kConfiguration.getSections().getSection(JCacheConfiguration.class);
if (_extraConfigurationSpecified != null) {
extraConfiguration = _extraConfigurationSpecified;
}
}
}
Aggregations