Restructure Redis HttpSession configuration support
This commit restructures configuration support for Redis-backed HttpSession with aim to enable users to easily select the SessionRepository implementation they prefer to use. This is achieved by introducing [at]EnableRedisIndexedHttpSession annotation that can be used to configure RedisIndexedSessionRepository, while the existing [at]EnableRedisHttpSession will going forward configure RedisSessionRepository as the SessionRepository implementation used by Spring Session. Additionally, this also introduces AbstractRedisHttpSessionConfiguration as the base configuration class that manages common aspects of Redis-backed HttpSession support, which is then extended by more specific configuration classes that provide specific SessionRepository implementation. Closes gh-2122
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
* Copyright 2014-2022 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.
|
||||
@@ -130,7 +130,7 @@ class IndexDocTests {
|
||||
@SuppressWarnings("unused")
|
||||
void newRedisIndexedSessionRepository() {
|
||||
// tag::new-redisindexedsessionrepository[]
|
||||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
|
||||
// ... configure redisTemplate ...
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
|
||||
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisIndexedHttpSessionConfiguration"/>
|
||||
|
||||
<!-- tag::configure-redis-action[] -->
|
||||
<util:constant
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
<context:annotation-config/>
|
||||
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
|
||||
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisIndexedHttpSessionConfiguration"/>
|
||||
|
||||
<bean class="docs.http.AbstractHttpSessionListenerTests"
|
||||
factory-method="createMockRedisConnection"/>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*** HttpSession
|
||||
**** Redis
|
||||
***** {gh-samples-url}spring-session-sample-boot-redis-json[JSON serialization]
|
||||
***** {gh-samples-url}spring-session-sample-boot-redis-simple[Simple Redis]
|
||||
***** xref:guides/boot-redis.adoc[Redis with Events]
|
||||
**** xref:guides/boot-mongo.adoc[MongoDB]
|
||||
**** xref:guides/boot-jdbc.adoc[JDBC]
|
||||
|
||||
@@ -39,10 +39,6 @@ To get started with Spring Session, the best place to start is our Sample Applic
|
||||
| Demonstrates how to use Spring Session to replace the `HttpSession` with Redis using JSON serialization.
|
||||
|
|
||||
|
||||
| {gh-samples-url}spring-session-sample-boot-redis-simple[HttpSession with simple Redis `SessionRepository`]
|
||||
| Demonstrates how to use Spring Session to replace the `HttpSession` with Redis using `RedisSessionRepository`.
|
||||
|
|
||||
|
||||
| {gh-samples-url}spring-session-sample-boot-mongodb-traditional[Spring Session with MongoDB Repositories (servlet-based)]
|
||||
| Demonstrates how to back Spring Session with traditional MongoDB repositories.
|
||||
| link:guides/boot-mongo.html[Spring Session with MongoDB Repositories]
|
||||
|
||||
Reference in New Issue
Block a user