Restore proper customization of JCache CacheManager
Work in 1b3efd4 actually introduced a regression: if a CacheManager is
created via a custom configuration file, it is no longer post-processed.
This commit makes sure to also customize a CacheManager that was
created that way.
See gh-2848
This commit is contained in:
parent
c0e9ed1e34
commit
b466229231
|
|
@ -77,15 +77,7 @@ class JCacheCacheConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public CacheManager jCacheCacheManager() throws IOException {
|
public CacheManager jCacheCacheManager() throws IOException {
|
||||||
CachingProvider cachingProvider = getCachingProvider(this.cacheProperties
|
CacheManager jCacheCacheManager = createCacheManager();
|
||||||
.getJcache().getProvider());
|
|
||||||
Resource configLocation = this.cacheProperties.resolveConfigLocation();
|
|
||||||
if (configLocation != null) {
|
|
||||||
return cachingProvider.getCacheManager(configLocation.getURI(),
|
|
||||||
cachingProvider.getDefaultClassLoader(),
|
|
||||||
createCacheManagerProperties(configLocation));
|
|
||||||
}
|
|
||||||
CacheManager jCacheCacheManager = cachingProvider.getCacheManager();
|
|
||||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||||
if (!CollectionUtils.isEmpty(cacheNames)) {
|
if (!CollectionUtils.isEmpty(cacheNames)) {
|
||||||
for (String cacheName : cacheNames) {
|
for (String cacheName : cacheNames) {
|
||||||
|
|
@ -96,6 +88,18 @@ class JCacheCacheConfiguration {
|
||||||
return jCacheCacheManager;
|
return jCacheCacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CacheManager createCacheManager() throws IOException {
|
||||||
|
CachingProvider cachingProvider = getCachingProvider(this.cacheProperties
|
||||||
|
.getJcache().getProvider());
|
||||||
|
Resource configLocation = this.cacheProperties.resolveConfigLocation();
|
||||||
|
if (configLocation != null) {
|
||||||
|
return cachingProvider.getCacheManager(configLocation.getURI(),
|
||||||
|
cachingProvider.getDefaultClassLoader(),
|
||||||
|
createCacheManagerProperties(configLocation));
|
||||||
|
}
|
||||||
|
return cachingProvider.getCacheManager();
|
||||||
|
}
|
||||||
|
|
||||||
private CachingProvider getCachingProvider(String cachingProviderFqn) {
|
private CachingProvider getCachingProvider(String cachingProviderFqn) {
|
||||||
if (StringUtils.hasText(cachingProviderFqn)) {
|
if (StringUtils.hasText(cachingProviderFqn)) {
|
||||||
return Caching.getCachingProvider(cachingProviderFqn);
|
return Caching.getCachingProvider(cachingProviderFqn);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue