Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a9b2826c
Commit
a9b2826c
authored
Jun 04, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x' into 2.0.x
parents
6be208ed
a562cb5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
JCacheCacheConfiguration.java
...rk/boot/autoconfigure/cache/JCacheCacheConfiguration.java
+12
-4
CacheAutoConfigurationTests.java
...boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+14
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java
View file @
a9b2826c
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -26,6 +26,7 @@ import javax.cache.Caching;
import
javax.cache.configuration.MutableConfiguration
;
import
javax.cache.spi.CachingProvider
;
import
org.springframework.beans.factory.BeanClassLoaderAware
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.condition.AnyNestedCondition
;
import
org.springframework.boot.autoconfigure.condition.ConditionMessage
;
...
...
@@ -61,7 +62,7 @@ import org.springframework.util.StringUtils;
@Conditional
({
CacheCondition
.
class
,
JCacheCacheConfiguration
.
JCacheAvailableCondition
.
class
})
@Import
(
HazelcastJCacheCustomizationConfiguration
.
class
)
class
JCacheCacheConfiguration
{
class
JCacheCacheConfiguration
implements
BeanClassLoaderAware
{
private
final
CacheProperties
cacheProperties
;
...
...
@@ -73,6 +74,8 @@ class JCacheCacheConfiguration {
private
final
List
<
JCachePropertiesCustomizer
>
cachePropertiesCustomizers
;
private
ClassLoader
beanClassLoader
;
JCacheCacheConfiguration
(
CacheProperties
cacheProperties
,
CacheManagerCustomizers
customizers
,
ObjectProvider
<
javax
.
cache
.
configuration
.
Configuration
<?,
?>>
defaultCacheConfiguration
,
...
...
@@ -85,6 +88,11 @@ class JCacheCacheConfiguration {
this
.
cachePropertiesCustomizers
=
cachePropertiesCustomizers
.
getIfAvailable
();
}
@Override
public
void
setBeanClassLoader
(
ClassLoader
classLoader
)
{
this
.
beanClassLoader
=
classLoader
;
}
@Bean
public
JCacheCacheManager
cacheManager
(
CacheManager
jCacheCacheManager
)
{
JCacheCacheManager
cacheManager
=
new
JCacheCacheManager
(
jCacheCacheManager
);
...
...
@@ -113,9 +121,9 @@ class JCacheCacheConfiguration {
.
resolveConfigLocation
(
this
.
cacheProperties
.
getJcache
().
getConfig
());
if
(
configLocation
!=
null
)
{
return
cachingProvider
.
getCacheManager
(
configLocation
.
getURI
(),
cachingProvider
.
getDefaultClassLoader
()
,
properties
);
this
.
beanClassLoader
,
properties
);
}
return
cachingProvider
.
getCacheManager
(
null
,
null
,
properties
);
return
cachingProvider
.
getCacheManager
(
null
,
this
.
beanClassLoader
,
properties
);
}
private
CachingProvider
getCachingProvider
(
String
cachingProviderFqn
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
View file @
a9b2826c
...
...
@@ -469,6 +469,20 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
.
hasMessageContaining
(
configLocation
));
}
@Test
public
void
jCacheCacheUseBeanClassLoader
()
{
String
cachingProviderFqn
=
MockCachingProvider
.
class
.
getName
();
this
.
contextRunner
.
withUserConfiguration
(
DefaultCacheConfiguration
.
class
)
.
withPropertyValues
(
"spring.cache.type=jcache"
,
"spring.cache.jcache.provider="
+
cachingProviderFqn
)
.
run
((
context
)
->
{
JCacheCacheManager
cacheManager
=
getCacheManager
(
context
,
JCacheCacheManager
.
class
);
assertThat
(
cacheManager
.
getCacheManager
().
getClassLoader
())
.
isEqualTo
(
context
.
getClassLoader
());
});
}
@Test
public
void
hazelcastCacheExplicit
()
{
this
.
contextRunner
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment