Revert "Enable customization of properties used to create JCache CacheManager"

This reverts commit 622c9ed882 that was
pushed accidentally.
This commit is contained in:
Andy Wilkinson 2024-06-24 12:03:13 +01:00
parent 94336ab314
commit 6bdba8e69e
3 changed files with 16 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,26 +38,21 @@ import org.springframework.core.io.Resource;
class HazelcastJCacheCustomizationConfiguration {
@Bean
HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider<HazelcastInstance> hazelcastInstance,
CacheProperties cacheProperties) {
return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique(), cacheProperties);
HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider<HazelcastInstance> hazelcastInstance) {
return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique());
}
static class HazelcastPropertiesCustomizer implements JCachePropertiesCustomizer {
private final HazelcastInstance hazelcastInstance;
private final CacheProperties cacheProperties;
HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance, CacheProperties cacheProperties) {
HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance) {
this.hazelcastInstance = hazelcastInstance;
this.cacheProperties = cacheProperties;
}
@Override
public void customize(Properties properties) {
Resource configLocation = this.cacheProperties
.resolveConfigLocation(this.cacheProperties.getJcache().getConfig());
public void customize(CacheProperties cacheProperties, Properties properties) {
Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig());
if (configLocation != null) {
// Hazelcast does not use the URI as a mean to specify a custom config.
properties.setProperty("hazelcast.config.location", toUri(configLocation).toString());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -95,7 +95,7 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
private CacheManager createCacheManager(CacheProperties cacheProperties,
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers) throws IOException {
CachingProvider cachingProvider = getCachingProvider(cacheProperties.getJcache().getProvider());
Properties properties = createCacheManagerProperties(cachePropertiesCustomizers);
Properties properties = createCacheManagerProperties(cachePropertiesCustomizers, cacheProperties);
Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig());
if (configLocation != null) {
return cachingProvider.getCacheManager(configLocation.getURI(), this.beanClassLoader, properties);
@ -111,9 +111,10 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
}
private Properties createCacheManagerProperties(
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers) {
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers, CacheProperties cacheProperties) {
Properties properties = new Properties();
cachePropertiesCustomizers.orderedStream().forEach((customizer) -> customizer.customize(properties));
cachePropertiesCustomizers.orderedStream()
.forEach((customizer) -> customizer.customize(cacheProperties, properties));
return properties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,17 +25,16 @@ import javax.cache.spi.CachingProvider;
* Callback interface that can be implemented by beans wishing to customize the properties
* used by the {@link CachingProvider} to create the {@link CacheManager}.
*
* @see CachingProvider#getCacheManager(java.net.URI, ClassLoader, Properties)
* @author Stephane Nicoll
* @since 3.3.0
*/
public interface JCachePropertiesCustomizer {
interface JCachePropertiesCustomizer {
/**
* Customize the properties.
* @param cacheProperties the cache properties
* @param properties the current properties
*
* @see CachingProvider#getCacheManager(java.net.URI, ClassLoader, Properties)
*/
void customize(Properties properties);
void customize(CacheProperties cacheProperties, Properties properties);
}