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
de4e3508
Commit
de4e3508
authored
Jan 04, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
e9021b36
0a26a414
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
47 deletions
+5
-47
RedisSessionConfiguration.java
...boot/autoconfigure/session/RedisSessionConfiguration.java
+1
-16
SessionCondition.java
...ramework/boot/autoconfigure/session/SessionCondition.java
+2
-10
SessionAutoConfigurationRedisTests.java
...configure/session/SessionAutoConfigurationRedisTests.java
+1
-17
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-4
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/RedisSessionConfiguration.java
View file @
de4e3508
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -16,11 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
session
;
import
javax.annotation.PostConstruct
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -45,8 +40,6 @@ import org.springframework.session.data.redis.config.annotation.web.http.RedisHt
@Conditional
(
SessionCondition
.
class
)
class
RedisSessionConfiguration
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
RedisSessionConfiguration
.
class
);
@Configuration
public
static
class
SpringBootRedisHttpSessionConfiguration
extends
RedisHttpSessionConfiguration
{
...
...
@@ -65,14 +58,6 @@ class RedisSessionConfiguration {
setRedisFlushMode
(
redis
.
getFlushMode
());
}
@PostConstruct
public
void
validate
()
{
if
(
this
.
sessionProperties
.
getStoreType
()
==
null
)
{
logger
.
warn
(
"Spring Session store type is mandatory: set "
+
"'spring.session.store-type=redis' in your configuration"
);
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionCondition.java
View file @
de4e3508
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -23,19 +23,15 @@ import org.springframework.boot.bind.RelaxedPropertyResolver;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
org.springframework.core.type.AnnotationMetadata
;
import
org.springframework.util.ClassUtils
;
/**
* General condition used with all session configuration classes.
*
* @author Tommy Ludwig
* @author Stephane Nicoll
*/
class
SessionCondition
extends
SpringBootCondition
{
private
static
final
boolean
redisPresent
=
ClassUtils
.
isPresent
(
"org.springframework.data.redis.core.RedisTemplate"
,
SessionCondition
.
class
.
getClassLoader
());
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
...
...
@@ -46,10 +42,6 @@ class SessionCondition extends SpringBootCondition {
StoreType
sessionStoreType
=
SessionStoreMappings
.
getType
(((
AnnotationMetadata
)
metadata
).
getClassName
());
if
(!
resolver
.
containsProperty
(
"store-type"
))
{
if
(
sessionStoreType
==
StoreType
.
REDIS
&&
redisPresent
)
{
return
ConditionOutcome
.
match
(
message
.
foundExactly
(
"default store type of redis (deprecated)"
));
}
return
ConditionOutcome
.
noMatch
(
message
.
didNotFind
(
"spring.session.store-type property"
).
atAll
());
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
View file @
de4e3508
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -24,13 +24,10 @@ import org.junit.Test;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
;
import
org.springframework.boot.redis.RedisTestServer
;
import
org.springframework.boot.test.rule.OutputCapture
;
import
org.springframework.session.data.redis.RedisFlushMode
;
import
org.springframework.session.data.redis.RedisOperationsSessionRepository
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
/**
* Redis specific tests for {@link SessionAutoConfiguration}.
...
...
@@ -40,27 +37,14 @@ import static org.hamcrest.Matchers.containsString;
public
class
SessionAutoConfigurationRedisTests
extends
AbstractSessionAutoConfigurationTests
{
@Rule
public
OutputCapture
output
=
new
OutputCapture
();
@Rule
public
final
RedisTestServer
redis
=
new
RedisTestServer
();
@Test
public
void
redisSessionStoreIsTheDefault
()
{
load
(
Collections
.<
Class
<?>>
singletonList
(
RedisAutoConfiguration
.
class
));
validateSpringSessionUsesRedis
();
this
.
output
.
expect
(
containsString
(
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"
));
}
@Test
public
void
redisSessionStore
()
{
load
(
Collections
.<
Class
<?>>
singletonList
(
RedisAutoConfiguration
.
class
),
"spring.session.store-type=redis"
);
validateSpringSessionUsesRedis
();
this
.
output
.
expect
(
not
(
containsString
(
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"
)));
}
private
void
validateSpringSessionUsesRedis
()
{
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
de4e3508
...
...
@@ -4959,7 +4959,7 @@ Spring Boot provides Spring Session auto-configuration for a wide range of store
* Hazelcast
* HashMap
If Spring Session is available, you
only need to
choose the
If Spring Session is available, you
must
choose the
{sc-spring-boot-autoconfigure}/session/StoreType.{sc-ext}[`StoreType`] that you wish to
use to store the sessions. For instance to use JDBC as backend store, you'd configure
your application as follows:
...
...
@@ -4969,9 +4969,6 @@ your application as follows:
spring.session.store-type=jdbc
----
NOTE: For backward compatibility if Redis is available Spring Session will be automatically
configured to use Redis.
TIP: You can disable Spring Session by setting the `store-type` to `none`.
Each store has specific additional settings. For instance it is possible to customize
...
...
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