Remove Spring Session Mongo support

Remove auto-configuration support for Spring Session Mongo since it is
no longer supported in Spring Session 2.0.

See gh-9011
pull/9011/merge
Vedran Pavic 8 years ago committed by Phillip Webb
parent 30eba451d9
commit 33dd9d6d84

@ -1,55 +0,0 @@
/*
* Copyright 2012-2016 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.session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.session.SessionRepository;
import org.springframework.session.data.mongo.config.annotation.web.http.MongoHttpSessionConfiguration;
/**
* Mongo backed session configuration.
*
* @author Eddú Meléndez
* @author Stephane Nicoll
*/
@Configuration
@ConditionalOnMissingBean(SessionRepository.class)
@ConditionalOnBean(MongoOperations.class)
@Conditional(SessionCondition.class)
class MongoSessionConfiguration {
@Configuration
public static class SpringBootMongoHttpSessionConfiguration
extends MongoHttpSessionConfiguration {
@Autowired
public void customize(SessionProperties sessionProperties) {
Integer timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
}
setCollectionName(sessionProperties.getMongo().getCollectionName());
}
}
}

@ -29,7 +29,6 @@ import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration.SessionConfigurationImportSelector;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration.SessionRepositoryValidator;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -48,6 +47,7 @@ import org.springframework.util.Assert;
* @author Tommy Ludwig
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Vedran Pavic
* @since 1.4.0
*/
@Configuration
@ -56,8 +56,7 @@ import org.springframework.util.Assert;
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(SessionProperties.class)
@AutoConfigureAfter({ DataSourceAutoConfiguration.class, HazelcastAutoConfiguration.class,
JdbcTemplateAutoConfiguration.class, MongoAutoConfiguration.class,
RedisAutoConfiguration.class })
JdbcTemplateAutoConfiguration.class, RedisAutoConfiguration.class })
@Import({ SessionConfigurationImportSelector.class, SessionRepositoryValidator.class,
SessionRepositoryFilterConfiguration.class })
public class SessionAutoConfiguration {

@ -44,8 +44,6 @@ public class SessionProperties {
private final Jdbc jdbc = new Jdbc();
private final Mongo mongo = new Mongo();
private final Redis redis = new Redis();
public SessionProperties(ObjectProvider<ServerProperties> serverProperties) {
@ -78,10 +76,6 @@ public class SessionProperties {
return this.jdbc;
}
public Mongo getMongo() {
return this.mongo;
}
public Redis getRedis() {
return this.redis;
}
@ -183,23 +177,6 @@ public class SessionProperties {
}
public static class Mongo {
/**
* Collection name used to store sessions.
*/
private String collectionName = "sessions";
public String getCollectionName() {
return this.collectionName;
}
public void setCollectionName(String collectionName) {
this.collectionName = collectionName;
}
}
public static class Redis {
/**

@ -35,7 +35,6 @@ final class SessionStoreMappings {
static {
Map<StoreType, Class<?>> mappings = new HashMap<>();
mappings.put(StoreType.REDIS, RedisSessionConfiguration.class);
mappings.put(StoreType.MONGO, MongoSessionConfiguration.class);
mappings.put(StoreType.JDBC, JdbcSessionConfiguration.class);
mappings.put(StoreType.HAZELCAST, HazelcastSessionConfiguration.class);
mappings.put(StoreType.HASH_MAP, HashMapSessionConfiguration.class);

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -21,6 +21,7 @@ package org.springframework.boot.autoconfigure.session;
*
* @author Tommy Ludwig
* @author Eddú Meléndez
* @author Vedran Pavic
* @since 1.4.0
*/
public enum StoreType {
@ -30,11 +31,6 @@ public enum StoreType {
*/
REDIS,
/**
* Mongo backed sessions.
*/
MONGO,
/**
* JDBC backed sessions.
*/

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.session;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
@ -26,18 +25,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository;
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.session.web.http.SessionRepositoryFilter;
import org.springframework.test.util.ReflectionTestUtils;
@ -49,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Vedran Pavic
*/
public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTests {
@ -72,7 +67,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
@Test
public void backOffIfSessionRepositoryIsPresent() {
load(Collections.<Class<?>>singletonList(SessionRepositoryConfiguration.class),
"spring.session.store-type=mongo");
"spring.session.store-type=redis");
MapSessionRepository repository = validateSessionRepository(
MapSessionRepository.class);
assertThat(this.context.getBean("mySessionRepository")).isSameAs(repository);
@ -102,26 +97,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
assertThat(getSessionTimeout(repository)).isNull();
}
@Test
public void mongoSessionStore() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
"spring.session.store-type=mongo");
validateSessionRepository(MongoOperationsSessionRepository.class);
}
@Test
public void mongoSessionStoreWithCustomizations() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
"spring.session.store-type=mongo",
"spring.session.mongo.collection-name=foobar");
MongoOperationsSessionRepository repository = validateSessionRepository(
MongoOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("collectionName"))
.isEqualTo("foobar");
}
@Test
public void validationFailsIfSessionRepositoryIsNotConfigured() {
this.thrown.expect(BeanCreationException.class);

@ -2246,11 +2246,6 @@
<artifactId>spring-session-data-gemfire</artifactId>
<version>${spring-session.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-mongo</artifactId>
<version>${spring-session.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-hazelcast</artifactId>

@ -414,7 +414,6 @@ content into your application; rather pick only the properties that you need.
spring.session.jdbc.initializer.enabled= # Create the required session tables on startup if necessary. Enabled automatically if the default table name is set or a custom schema is configured.
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.
spring.session.mongo.collection-name=sessions # Collection name used to store sessions.
spring.session.redis.flush-mode=on-save # Sessions flush mode.
spring.session.redis.namespace= # Namespace for keys used to store sessions.
spring.session.store-type= # Session store type.

@ -5138,7 +5138,6 @@ classes for more details.
Spring Boot provides Spring Session auto-configuration for a wide range of stores:
* JDBC
* MongoDB
* Redis
* Hazelcast
* HashMap

Loading…
Cancel
Save