From 322b03779d73dcbd02a838a62d37fb5e1e354821 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 3 Dec 2013 12:11:07 +0000 Subject: [PATCH] Upgrade Thymeleaf and Spring --- .../thymeleaf/ThymeleafAutoConfiguration.java | 30 +++++-------------- .../websocket/WebSocketAutoConfiguration.java | 17 ++++++----- spring-boot-dependencies/pom.xml | 8 ++--- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index a14ec54478..c12980b979 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.thymeleaf; -import java.io.IOException; -import java.io.InputStream; import java.util.Collection; import java.util.Collections; @@ -39,11 +37,10 @@ import org.springframework.core.Ordered; import org.springframework.core.env.Environment; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.ResourceLoader; -import org.thymeleaf.TemplateProcessingParameters; import org.thymeleaf.dialect.IDialect; import org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect; -import org.thymeleaf.resourceresolver.IResourceResolver; import org.thymeleaf.spring3.SpringTemplateEngine; +import org.thymeleaf.spring3.resourceresolver.SpringResourceResourceResolver; import org.thymeleaf.spring3.view.ThymeleafViewResolver; import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.TemplateResolver; @@ -79,25 +76,7 @@ public class ThymeleafAutoConfiguration { @Bean public ITemplateResolver defaultTemplateResolver() { TemplateResolver resolver = new TemplateResolver(); - resolver.setResourceResolver(new IResourceResolver() { - @Override - public InputStream getResourceAsStream( - TemplateProcessingParameters templateProcessingParameters, - String resourceName) { - try { - return DefaultTemplateResolverConfiguration.this.resourceLoader - .getResource(resourceName).getInputStream(); - } - catch (IOException ex) { - return null; - } - } - - @Override - public String getName() { - return "SPRING"; - } - }); + resolver.setResourceResolver(thymeleafResourceResolver()); resolver.setPrefix(this.environment.getProperty("prefix", DEFAULT_PREFIX)); resolver.setSuffix(this.environment.getProperty("suffix", DEFAULT_SUFFIX)); resolver.setTemplateMode(this.environment.getProperty("mode", "HTML5")); @@ -108,6 +87,11 @@ public class ThymeleafAutoConfiguration { return resolver; } + @Bean + protected SpringResourceResourceResolver thymeleafResourceResolver() { + return new SpringResourceResourceResolver(); + } + public static boolean templateExists(Environment environment, ResourceLoader resourceLoader, String view) { String prefix = environment.getProperty("spring.thymeleaf.prefix", diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java index 0091282208..8b9e15c159 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java @@ -39,17 +39,18 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.util.ClassUtils; import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.server.config.EnableWebSocket; -import org.springframework.web.socket.server.config.WebSocketConfigurer; -import org.springframework.web.socket.server.config.WebSocketHandlerRegistry; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService; /** - * Auto configuration for websockets (and sockjs in particular). Users should be able to - * just define beans of type {@link WebSocketHandler}. If spring-websocket is - * detected on the classpath then we add a {@link DefaultSockJsService} and an MVC handler - * mapping to /<beanName>/** for all of the - * WebSocketHandler beans that have a bean name beginning with "/". + * Auto configuration for websocket server (and sockjs in particular). Users should be + * able to just define beans of type {@link WebSocketHandler}. If + * spring-websocket is detected on the classpath then we add a + * {@link DefaultSockJsService} and an MVC handler mapping to + * /<beanName>/** for all of the WebSocketHandler beans + * that have a bean name beginning with "/". * * @author Dave Syer */ diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 1a66fa1c4c..b261d11b7b 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -37,7 +37,7 @@ 1.12 0.7-groovy-2.0 4.0.0.BUILD-SNAPSHOT - 2.2.4.RELEASE + 2.2.6.RELEASE 1.0.0.M1 2.2.2.RELEASE 1.4.2.RELEASE @@ -46,9 +46,9 @@ 1.2.0.RELEASE 1.1.0.RELEASE 3.2.0.RC2 - 2.0.19 - 2.0.1 - 1.1.3 + 2.1.1.RELEASE + 2.1.0.RELEASE + 1.2 7.0.47 1.3.0-beta11 1.1.5