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
d0fd6145
Commit
d0fd6145
authored
Jun 10, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CacheType outer class tangle
Fixes gh-3168
parent
5312be4a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
31 deletions
+75
-31
CacheAutoConfiguration.java
...work/boot/autoconfigure/cache/CacheAutoConfiguration.java
+1
-1
CacheCondition.java
...ingframework/boot/autoconfigure/cache/CacheCondition.java
+2
-2
CacheConfigurations.java
...amework/boot/autoconfigure/cache/CacheConfigurations.java
+63
-0
CacheType.java
...g/springframework/boot/autoconfigure/cache/CacheType.java
+9
-28
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java
View file @
d0fd6145
...
...
@@ -131,7 +131,7 @@ public class CacheAutoConfiguration {
CacheType
[]
types
=
CacheType
.
values
();
String
[]
imports
=
new
String
[
types
.
length
];
for
(
int
i
=
0
;
i
<
types
.
length
;
i
++)
{
imports
[
i
]
=
types
[
i
].
getConfigurationClass
().
getName
(
);
imports
[
i
]
=
CacheConfigurations
.
getConfigurationClass
(
types
[
i
]
);
}
return
imports
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java
View file @
d0fd6145
...
...
@@ -40,8 +40,8 @@ class CacheCondition extends SpringBootCondition {
if
(!
resolver
.
containsProperty
(
"type"
))
{
return
ConditionOutcome
.
match
(
"Automatic cache type"
);
}
CacheType
cacheType
=
Cache
Type
.
forConfigurationClass
(((
AnnotationMetadata
)
metadata
).
getClassName
());
CacheType
cacheType
=
Cache
Configurations
.
getType
(((
AnnotationMetadata
)
metadata
)
.
getClassName
());
String
value
=
resolver
.
getProperty
(
"type"
).
replace
(
"-"
,
"_"
).
toUpperCase
();
if
(
value
.
equals
(
cacheType
.
name
()))
{
return
ConditionOutcome
.
match
(
"Cache type "
+
cacheType
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java
0 → 100644
View file @
d0fd6145
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
cache
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.util.Assert
;
/**
* Mappings between {@link CacheType} and {@code @Configuration}.
*
* @author Phillip Webb
*/
class
CacheConfigurations
{
private
static
final
Map
<
CacheType
,
Class
<?>>
MAPPINGS
;
static
{
Map
<
CacheType
,
Class
<?>>
mappings
=
new
HashMap
<
CacheType
,
Class
<?>>();
mappings
.
put
(
CacheType
.
GENERIC
,
GenericCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
EHCACHE
,
EhCacheCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
HAZELCAST
,
HazelcastCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
INFINISPAN
,
InfinispanCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
JCACHE
,
JCacheCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
REDIS
,
RedisCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
GUAVA
,
GuavaCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
SIMPLE
,
SimpleCacheConfiguration
.
class
);
mappings
.
put
(
CacheType
.
NONE
,
NoOpCacheConfiguration
.
class
);
MAPPINGS
=
Collections
.
unmodifiableMap
(
mappings
);
}
public
static
String
getConfigurationClass
(
CacheType
cacheType
)
{
Class
<?>
configurationClass
=
MAPPINGS
.
get
(
cacheType
);
Assert
.
state
(
configurationClass
!=
null
,
"Unknown cache type "
+
cacheType
);
return
configurationClass
.
getName
();
}
public
static
CacheType
getType
(
String
configurationClassName
)
{
for
(
Map
.
Entry
<
CacheType
,
Class
<?>>
entry
:
MAPPINGS
.
entrySet
())
{
if
(
entry
.
getValue
().
getName
().
equals
(
configurationClassName
))
{
return
entry
.
getKey
();
}
}
throw
new
IllegalStateException
(
"Unknown configuration class "
+
configurationClassName
);
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheType.java
View file @
d0fd6145
...
...
@@ -29,65 +29,46 @@ public enum CacheType {
/**
* Generic caching using 'Cache' beans from the context.
*/
GENERIC
(
GenericCacheConfiguration
.
class
)
,
GENERIC
,
/**
* EhCache backed caching.
*/
EHCACHE
(
EhCacheCacheConfiguration
.
class
)
,
EHCACHE
,
/**
* Hazelcast backed caching
*/
HAZELCAST
(
HazelcastCacheConfiguration
.
class
)
,
HAZELCAST
,
/**
* Infinispan backed caching.
*/
INFINISPAN
(
InfinispanCacheConfiguration
.
class
)
,
INFINISPAN
,
/**
* JCache (JSR-107) backed caching.
*/
JCACHE
(
JCacheCacheConfiguration
.
class
)
,
JCACHE
,
/**
* Redis backed caching.
*/
REDIS
(
RedisCacheConfiguration
.
class
)
,
REDIS
,
/**
* Guava backed caching.
*/
GUAVA
(
GuavaCacheConfiguration
.
class
)
,
GUAVA
,
/**
* Simple in-memory caching.
*/
SIMPLE
(
SimpleCacheConfiguration
.
class
)
,
SIMPLE
,
/**
* No caching.
*/
NONE
(
NoOpCacheConfiguration
.
class
);
private
final
Class
<?>
configurationClass
;
CacheType
(
Class
<?>
configurationClass
)
{
this
.
configurationClass
=
configurationClass
;
}
Class
<?>
getConfigurationClass
()
{
return
this
.
configurationClass
;
}
static
CacheType
forConfigurationClass
(
String
configurationClass
)
{
for
(
CacheType
type
:
values
())
{
if
(
type
.
getConfigurationClass
().
getName
().
equals
(
configurationClass
))
{
return
type
;
}
}
throw
new
IllegalArgumentException
(
"Unsupported class "
+
configurationClass
);
}
NONE
;
}
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