40
40
import org .springframework .context .annotation .ConditionContext ;
41
41
import org .springframework .context .annotation .Conditional ;
42
42
import org .springframework .context .annotation .Configuration ;
43
+ import org .springframework .context .annotation .Import ;
43
44
import org .springframework .core .Ordered ;
44
45
import org .springframework .core .annotation .AnnotationAwareOrderComparator ;
45
46
import org .springframework .core .annotation .Order ;
59
60
@ ConditionalOnMissingBean (org .springframework .cache .CacheManager .class )
60
61
@ Conditional ({ CacheCondition .class ,
61
62
JCacheCacheConfiguration .JCacheAvailableCondition .class })
63
+ @ Import (HazelcastJCacheCustomizationConfiguration .class )
62
64
class JCacheCacheConfiguration {
63
65
64
66
private final CacheProperties cacheProperties ;
@@ -69,14 +71,18 @@ class JCacheCacheConfiguration {
69
71
70
72
private final List <JCacheManagerCustomizer > cacheManagerCustomizers ;
71
73
74
+ private final List <JCachePropertiesCustomizer > cachePropertiesCustomizers ;
75
+
72
76
JCacheCacheConfiguration (CacheProperties cacheProperties ,
73
77
CacheManagerCustomizers customizers ,
74
78
ObjectProvider <javax .cache .configuration .Configuration <?, ?>> defaultCacheConfiguration ,
75
- ObjectProvider <List <JCacheManagerCustomizer >> cacheManagerCustomizers ) {
79
+ ObjectProvider <List <JCacheManagerCustomizer >> cacheManagerCustomizers ,
80
+ ObjectProvider <List <JCachePropertiesCustomizer >> cachePropertiesCustomizers ) {
76
81
this .cacheProperties = cacheProperties ;
77
82
this .customizers = customizers ;
78
83
this .defaultCacheConfiguration = defaultCacheConfiguration .getIfAvailable ();
79
84
this .cacheManagerCustomizers = cacheManagerCustomizers .getIfAvailable ();
85
+ this .cachePropertiesCustomizers = cachePropertiesCustomizers .getIfAvailable ();
80
86
}
81
87
82
88
@ Bean
@@ -102,14 +108,14 @@ public CacheManager jCacheCacheManager() throws IOException {
102
108
private CacheManager createCacheManager () throws IOException {
103
109
CachingProvider cachingProvider = getCachingProvider (
104
110
this .cacheProperties .getJcache ().getProvider ());
111
+ Properties properties = createCacheManagerProperties ();
105
112
Resource configLocation = this .cacheProperties
106
113
.resolveConfigLocation (this .cacheProperties .getJcache ().getConfig ());
107
114
if (configLocation != null ) {
108
115
return cachingProvider .getCacheManager (configLocation .getURI (),
109
- cachingProvider .getDefaultClassLoader (),
110
- createCacheManagerProperties (configLocation ));
116
+ cachingProvider .getDefaultClassLoader (), properties );
111
117
}
112
- return cachingProvider .getCacheManager ();
118
+ return cachingProvider .getCacheManager (null , null , properties );
113
119
}
114
120
115
121
private CachingProvider getCachingProvider (String cachingProviderFqn ) {
@@ -119,12 +125,13 @@ private CachingProvider getCachingProvider(String cachingProviderFqn) {
119
125
return Caching .getCachingProvider ();
120
126
}
121
127
122
- private Properties createCacheManagerProperties (Resource configLocation )
123
- throws IOException {
128
+ private Properties createCacheManagerProperties () {
124
129
Properties properties = new Properties ();
125
- // Hazelcast does not use the URI as a mean to specify a custom config.
126
- properties .setProperty ("hazelcast.config.location" ,
127
- configLocation .getURI ().toString ());
130
+ if (this .cachePropertiesCustomizers != null ) {
131
+ for (JCachePropertiesCustomizer customizer : this .cachePropertiesCustomizers ) {
132
+ customizer .customize (this .cacheProperties , properties );
133
+ }
134
+ }
128
135
return properties ;
129
136
}
130
137
0 commit comments