26
26
import javax .cache .configuration .MutableConfiguration ;
27
27
import javax .cache .spi .CachingProvider ;
28
28
29
+ import org .springframework .beans .factory .BeanClassLoaderAware ;
29
30
import org .springframework .beans .factory .ObjectProvider ;
30
31
import org .springframework .boot .autoconfigure .condition .AnyNestedCondition ;
31
32
import org .springframework .boot .autoconfigure .condition .ConditionMessage ;
61
62
@ Conditional ({ CacheCondition .class ,
62
63
JCacheCacheConfiguration .JCacheAvailableCondition .class })
63
64
@ Import (HazelcastJCacheCustomizationConfiguration .class )
64
- class JCacheCacheConfiguration {
65
+ class JCacheCacheConfiguration implements BeanClassLoaderAware {
65
66
66
67
private final CacheProperties cacheProperties ;
67
68
@@ -73,6 +74,8 @@ class JCacheCacheConfiguration {
73
74
74
75
private final List <JCachePropertiesCustomizer > cachePropertiesCustomizers ;
75
76
77
+ private ClassLoader beanClassLoader ;
78
+
76
79
JCacheCacheConfiguration (CacheProperties cacheProperties ,
77
80
CacheManagerCustomizers customizers ,
78
81
ObjectProvider <javax .cache .configuration .Configuration <?, ?>> defaultCacheConfiguration ,
@@ -113,9 +116,9 @@ private CacheManager createCacheManager() throws IOException {
113
116
.resolveConfigLocation (this .cacheProperties .getJcache ().getConfig ());
114
117
if (configLocation != null ) {
115
118
return cachingProvider .getCacheManager (configLocation .getURI (),
116
- cachingProvider . getDefaultClassLoader () , properties );
119
+ this . beanClassLoader , properties );
117
120
}
118
- return cachingProvider .getCacheManager (null , null , properties );
121
+ return cachingProvider .getCacheManager (null , this . beanClassLoader , properties );
119
122
}
120
123
121
124
private CachingProvider getCachingProvider (String cachingProviderFqn ) {
@@ -151,6 +154,11 @@ private void customize(CacheManager cacheManager) {
151
154
}
152
155
}
153
156
157
+ @ Override
158
+ public void setBeanClassLoader (ClassLoader classLoader ) {
159
+ this .beanClassLoader = classLoader ;
160
+ }
161
+
154
162
/**
155
163
* Determine if JCache is available. This either kicks in if a provider is available
156
164
* as defined per {@link JCacheProviderAvailableCondition} or if a
0 commit comments