From 8bdcba6e50e682da844619bb42fadb197ba5b743 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 18 Jul 2017 20:07:43 -0500 Subject: [PATCH] Spring Session 2.0.0.M2 w/ Boot Samples This is necessary because the current version of Spring Session is not compatible with Boot 2.0.0.M2 and we cannot release against the SNAPSHOTs Issue gh-833 --- .../spring-session-sample-boot-findbyusername.gradle | 7 ++----- .../src/main/java/sample/mvc/IndexController.java | 10 +++++----- .../src/main/resources/templates/index.html | 4 ++-- .../boot/jdbc/spring-session-sample-boot-jdbc.gradle | 7 ++----- .../spring-session-sample-boot-redis-json.gradle | 7 +++---- .../boot/redis/spring-session-sample-boot-redis.gradle | 6 ++---- .../spring-session-sample-boot-websocket.gradle | 7 +++---- .../src/main/java/sample/config/WebSocketConfig.java | 6 +++--- .../java/sample/config/WebSocketHandlersConfig.java | 4 ++-- 9 files changed, 24 insertions(+), 34 deletions(-) diff --git a/samples/boot/findbyusername/spring-session-sample-boot-findbyusername.gradle b/samples/boot/findbyusername/spring-session-sample-boot-findbyusername.gradle index 94ee8163..f677cd38 100644 --- a/samples/boot/findbyusername/spring-session-sample-boot-findbyusername.gradle +++ b/samples/boot/findbyusername/spring-session-sample-boot-findbyusername.gradle @@ -1,22 +1,19 @@ apply plugin: 'io.spring.convention.spring-sample-boot' dependencies { - compile project(':spring-session-data-redis') + compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-starter-web" compile "org.springframework.boot:spring-boot-starter-thymeleaf" compile "org.springframework.boot:spring-boot-starter-security" - compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-devtools" + compile "org.springframework.session:spring-session" compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect" - compile "org.thymeleaf.extras:thymeleaf-extras-java8time" compile "org.webjars:bootstrap" compile "org.webjars:html5shiv" compile "org.webjars:webjars-locator" compile "com.maxmind.geoip2:geoip2" compile "org.apache.httpcomponents:httpclient" - compile project(':spring-session-hazelcast') - testCompile "org.springframework.boot:spring-boot-starter-test" testCompile "org.assertj:assertj-core" diff --git a/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java b/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java index 944590d8..9327f3d4 100644 --- a/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java +++ b/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-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. @@ -21,8 +21,8 @@ import java.util.Collection; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; -import org.springframework.session.Session; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; @@ -39,11 +39,11 @@ import org.springframework.web.bind.annotation.RequestMethod; public class IndexController { // tag::findbyusername[] @Autowired - FindByIndexNameSessionRepository sessions; + FindByIndexNameSessionRepository sessions; @RequestMapping("/") public String index(Principal principal, Model model) { - Collection usersSessions = this.sessions + Collection usersSessions = this.sessions .findByIndexNameAndIndexValue( FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principal.getName()) @@ -60,7 +60,7 @@ public class IndexController { FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principal.getName()).keySet(); if (usersSessionIds.contains(sessionIdToDelete)) { - this.sessions.deleteById(sessionIdToDelete); + this.sessions.delete(sessionIdToDelete); } return "redirect:/"; diff --git a/samples/boot/findbyusername/src/main/resources/templates/index.html b/samples/boot/findbyusername/src/main/resources/templates/index.html index 14dcb1bc..447b8a16 100644 --- a/samples/boot/findbyusername/src/main/resources/templates/index.html +++ b/samples/boot/findbyusername/src/main/resources/templates/index.html @@ -21,8 +21,8 @@ - - + +
diff --git a/samples/boot/jdbc/spring-session-sample-boot-jdbc.gradle b/samples/boot/jdbc/spring-session-sample-boot-jdbc.gradle index c76fc87e..5d8f31b3 100644 --- a/samples/boot/jdbc/spring-session-sample-boot-jdbc.gradle +++ b/samples/boot/jdbc/spring-session-sample-boot-jdbc.gradle @@ -1,21 +1,18 @@ apply plugin: 'io.spring.convention.spring-sample-boot' dependencies { - compile project(':spring-session-jdbc') + compile "org.springframework.boot:spring-boot-starter-jdbc" compile "org.springframework.boot:spring-boot-starter-web" compile "org.springframework.boot:spring-boot-starter-thymeleaf" compile "org.springframework.boot:spring-boot-starter-security" compile "org.springframework.boot:spring-boot-devtools" + compile "org.springframework.session:spring-session" compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect" compile "org.webjars:bootstrap" compile "org.webjars:html5shiv" compile "org.webjars:webjars-locator" compile "com.h2database:h2" - compile project(':spring-session-hazelcast') - compile project(':spring-session-data-redis') - compile "org.springframework.boot:spring-boot-starter-data-redis" - testCompile "org.springframework.boot:spring-boot-starter-test" testCompile "org.assertj:assertj-core" diff --git a/samples/boot/redis-json/spring-session-sample-boot-redis-json.gradle b/samples/boot/redis-json/spring-session-sample-boot-redis-json.gradle index ee7bc0b4..5fba1ee4 100644 --- a/samples/boot/redis-json/spring-session-sample-boot-redis-json.gradle +++ b/samples/boot/redis-json/spring-session-sample-boot-redis-json.gradle @@ -1,20 +1,19 @@ apply plugin: 'io.spring.convention.spring-sample-boot' dependencies { - compile project(':spring-session-data-redis') + compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-starter-web" compile "org.springframework.boot:spring-boot-starter-thymeleaf" compile "org.springframework.boot:spring-boot-starter-security" - compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-devtools" + compile "org.springframework.session:spring-session" compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect" compile "org.webjars:bootstrap" compile "org.webjars:html5shiv" compile "org.webjars:webjars-locator" + compile "io.lettuce:lettuce-core" compile "org.apache.httpcomponents:httpclient" - compile project(':spring-session-hazelcast') - testCompile "org.springframework.boot:spring-boot-starter-test" testCompile "org.assertj:assertj-core" testCompile "org.skyscreamer:jsonassert" diff --git a/samples/boot/redis/spring-session-sample-boot-redis.gradle b/samples/boot/redis/spring-session-sample-boot-redis.gradle index c83e5254..0900f95f 100644 --- a/samples/boot/redis/spring-session-sample-boot-redis.gradle +++ b/samples/boot/redis/spring-session-sample-boot-redis.gradle @@ -1,19 +1,17 @@ apply plugin: 'io.spring.convention.spring-sample-boot' dependencies { - compile project(':spring-session-data-redis') + compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-starter-web" compile "org.springframework.boot:spring-boot-starter-thymeleaf" compile "org.springframework.boot:spring-boot-starter-security" - compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-devtools" + compile "org.springframework.session:spring-session" compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect" compile "org.webjars:bootstrap" compile "org.webjars:html5shiv" compile "org.webjars:webjars-locator" - compile project(':spring-session-hazelcast') - testCompile "org.springframework.boot:spring-boot-starter-test" integrationTestCompile seleniumDependencies diff --git a/samples/boot/websocket/spring-session-sample-boot-websocket.gradle b/samples/boot/websocket/spring-session-sample-boot-websocket.gradle index 63989ea8..7864a80f 100644 --- a/samples/boot/websocket/spring-session-sample-boot-websocket.gradle +++ b/samples/boot/websocket/spring-session-sample-boot-websocket.gradle @@ -1,14 +1,14 @@ apply plugin: 'io.spring.convention.spring-sample-boot' dependencies { - compile project(':spring-session-data-redis') + compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-starter-web" compile "org.springframework.boot:spring-boot-starter-thymeleaf" compile "org.springframework.boot:spring-boot-starter-security" compile "org.springframework.boot:spring-boot-starter-data-jpa" - compile "org.springframework.boot:spring-boot-starter-data-redis" compile "org.springframework.boot:spring-boot-starter-websocket" compile "org.springframework.boot:spring-boot-devtools" + compile "org.springframework.session:spring-session" compile "org.springframework:spring-websocket" compile "org.springframework.security:spring-security-messaging" compile "org.springframework.security:spring-security-data" @@ -19,10 +19,9 @@ dependencies { compile "org.webjars:sockjs-client" compile "org.webjars:stomp-websocket" compile "org.webjars:webjars-locator" + compile "io.lettuce:lettuce-core" compile "com.h2database:h2" - compile project(':spring-session-hazelcast') - testCompile "org.springframework.boot:spring-boot-starter-test" testCompile "org.springframework.security:spring-security-test" } diff --git a/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java b/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java index abd602ef..8a28a553 100644 --- a/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java +++ b/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-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. @@ -19,7 +19,7 @@ package sample.config; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.session.Session; +import org.springframework.session.ExpiringSession; import org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; @@ -29,7 +29,7 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry; @EnableScheduling @EnableWebSocketMessageBroker public class WebSocketConfig - extends AbstractSessionWebSocketMessageBrokerConfigurer { // <1> + extends AbstractSessionWebSocketMessageBrokerConfigurer { // <1> protected void configureStompEndpoints(StompEndpointRegistry registry) { // <2> registry.addEndpoint("/messages").withSockJS(); diff --git a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java index bc59fe7d..6e0eeafe 100644 --- a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java +++ b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java @@ -23,7 +23,7 @@ import sample.websocket.WebSocketDisconnectHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.SimpMessageSendingOperations; -import org.springframework.session.Session; +import org.springframework.session.ExpiringSession; /** * These handlers are separated from WebSocketConfig because they are specific to this @@ -32,7 +32,7 @@ import org.springframework.session.Session; * @author Rob Winch */ @Configuration -public class WebSocketHandlersConfig { +public class WebSocketHandlersConfig { @Bean public WebSocketConnectHandler webSocketConnectHandler(