diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java index ff0206b2b75..7832328506e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2024 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,21 +38,26 @@ import org.springframework.core.io.Resource; class HazelcastJCacheCustomizationConfiguration { @Bean - HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider hazelcastInstance) { - return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique()); + HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider hazelcastInstance, + CacheProperties cacheProperties) { + return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique(), cacheProperties); } static class HazelcastPropertiesCustomizer implements JCachePropertiesCustomizer { private final HazelcastInstance hazelcastInstance; - HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance) { + private final CacheProperties cacheProperties; + + HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance, CacheProperties cacheProperties) { this.hazelcastInstance = hazelcastInstance; + this.cacheProperties = cacheProperties; } @Override - public void customize(CacheProperties cacheProperties, Properties properties) { - Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig()); + public void customize(Properties properties) { + Resource configLocation = this.cacheProperties + .resolveConfigLocation(this.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()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java index 07d9d3c4029..e040229da3e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 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 cachePropertiesCustomizers) throws IOException { CachingProvider cachingProvider = getCachingProvider(cacheProperties.getJcache().getProvider()); - Properties properties = createCacheManagerProperties(cachePropertiesCustomizers, cacheProperties); + Properties properties = createCacheManagerProperties(cachePropertiesCustomizers); Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig()); if (configLocation != null) { return cachingProvider.getCacheManager(configLocation.getURI(), this.beanClassLoader, properties); @@ -111,10 +111,9 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware { } private Properties createCacheManagerProperties( - ObjectProvider cachePropertiesCustomizers, CacheProperties cacheProperties) { + ObjectProvider cachePropertiesCustomizers) { Properties properties = new Properties(); - cachePropertiesCustomizers.orderedStream() - .forEach((customizer) -> customizer.customize(cacheProperties, properties)); + cachePropertiesCustomizers.orderedStream().forEach((customizer) -> customizer.customize(properties)); return properties; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java index c18886c17e9..80f942535b4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2024 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,16 +25,17 @@ 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 */ -interface JCachePropertiesCustomizer { +public 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(CacheProperties cacheProperties, Properties properties); + void customize(Properties properties); }