I am facing the same need of Issue #29542 to set custom object into Properties object that are passed into the CachingProvider.getCacheManager(URI, ClassLoader, Properties) call.

Specifically, I am setting up Infinispan with Spring Boot via the JCache method, as opposed to using infinispan-spring-boot3-starter-embedded or using InfinispanCacheConfiguration. Based on the Infinispan's JCacheManager documentation, it is possible to customize the global configuration and cache configuration using Java code. This can be achieved by passing in customizer function to the Properties object with GLOBAL_CONFIGURATION_CONSUMER and CACHE_CONFIGURATION_FUNCTION keys, and these functions will get called during CachingProvider.getCacheManager(URI, ClassLoader, Properties) and CacheManager.create(String, C) call respectively.

Here is an example configuration class demostrating the use of GLOBAL_CONFIGURATION_CONSUMER and CACHE_CONFIGURATION_FUNCTION keys:

@ConfigurationProperties(prefix = "mysystem.cache")
data class CacheConfigProperty(
  val dir: Path,
  val expire: Duration
)

@Configuration(proxyBeanMethods = false)
class MyCacheConfig {

  @Bean
  fun jCacheManager(
    cacheConfigProperty: CacheConfigProperty,
  ): CacheManager {
    val properties = System.getProperties()
    properties[JCacheManager.GLOBAL_CONFIGURATION_CONSUMER] = Consumer<GlobalConfigurationBuilder> {
      it.globalState().enable()
        .persistentLocation(cacheConfigProperty.dir.toString())
    }

    properties[JCacheManager.CACHE_CONFIGURATION_FUNCTION] = Function<String, org.infinispan.configuration.cache.Configuration> {
      return@Function if (it == "mylists") {
        ConfigurationBuilder()
          .persistence().passivation(false)
          .addSoftIndexFileStore()
          .shared(false)
          .preload(true)
          .expiration().lifespan(cacheConfigProperty.expire.toMillis(), TimeUnit.MILLISECONDS)
          .build()
      } else {
        null
      }
    }
    val cacheManager = Caching.getCachingProvider("org.infinispan.jcache.embedded.JCachingProvider")
        .getCacheManager(null, null, properties)
    cacheManager.createCache("mylists", MutableConfiguration<SimpleKey, String>())
    return cacheManager
  }
}

However, I would prefer to make use of JCacheCacheConfiguration class so that I can replace the cacheManager.createCache("mylists", MutableConfiguration<SimpleKey, String>()) call with the spring boot property spring.cache.cache-names=mylists

Comment From: wilkinsona

Making JCachePropertiesCustomizer public would encourage use of CacheProperties as public API which we discourage in the documentation. There are a few other places where we have a similar situation. If we're going to add to them, we should probably reconsider our policy for @ConfigurationProperties classes.

Comment From: CXwudi

I see. Not sure if this is a good idea, but how about introducing a new public customizer interface that takes a Properties object exclusively? It appears that both my issue and #29542 are primarily focused on altering the Properties object supplied to the CachingProvider.getCacheManager() method, rather than adjusting the Spring CacheProperties configuration property. (P.S: I noticed that CacheProperties is already a public class, implying that users have the ability to inject it into their application codes.)

Comment From: wilkinsona

I think we could even change the existing callback so that it only takes the Properties and update HazelcastPropertiesCustomizer to inject CacheProperties into its constructor instead:

https://github.com/wilkinsona/spring-boot/tree/gh-39350

Comment From: belowyoon

I created PR https://github.com/spring-projects/spring-boot/pull/41209, PTAL :)

Comment From: wilkinsona

Thanks, @belowyoon, but, as mentioned above, we already have these changes prepared in a branch that we'll merge in due course.