Class CacheCustomizerFactoryBean
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.boot.cache.autoconfigure.CacheManagerCustomizer<org.springframework.cache.CacheManager>
customize(...) method into a Spring Boot
CacheManagerCustomizer bean. The static method registers the service's cache regions with
the budget manager and returns a Consumer that registers the cache manager itself; that
consumer is applied here when Spring customizes a matching cache manager.
History: this class was previously a FactoryBean that produced a dynamic
proxy, in order to avoid compile-time linkage to the Spring Boot cache package (for Spring Boot
3/4 cross-compatibility). Under Spring Boot 4 that proxy was never applied: Spring Boot builds
its CacheManagerCustomizers from ObjectProvider<CacheManagerCustomizer<?>>
without eagerly initializing FactoryBeans, and a FactoryBean's
statically-declared product type is Object, so the proxy was never recognized as a
CacheManagerCustomizer and was silently excluded from the customizer list. Every service
that registered its caches this way therefore never registered with the budget manager and got no
cache.
Because the 3.x line targets Spring Boot 4, the cross-version reflection is no longer needed. By
implementing CacheManagerCustomizer directly, the bean's type is known from its
declaration (no instantiation required), so it is collected and applied like any other
customizer. The class name is retained to avoid touching the many service auto-configurations
that construct it.
-
Constructor Summary
ConstructorsConstructorDescriptionCacheCustomizerFactoryBean(Class<?> sourceClass, String methodName, Class<?> expectedCacheManagerClass) -
Method Summary
Modifier and TypeMethodDescriptionvoidcustomize(org.springframework.cache.CacheManager cacheManager) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
-
Constructor Details
-
CacheCustomizerFactoryBean
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware
-
customize
public void customize(org.springframework.cache.CacheManager cacheManager) - Specified by:
customizein interfaceorg.springframework.boot.cache.autoconfigure.CacheManagerCustomizer<org.springframework.cache.CacheManager>
-