From 6825a7b42ec43ae5d5443380d191b5f58ad316e8 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 28 Jul 2014 16:04:02 -0700 Subject: [PATCH] Polish --- .../autoconfigure/batch/BatchProperties.java | 13 +- ...legatingViewResolverAutoConfiguration.java | 10 +- ...eviceDelegatingViewResolverProperties.java | 24 +--- .../social/FacebookAutoConfiguration.java | 20 +-- .../social/FacebookProperties.java | 30 +++++ .../social/LinkedInAutoConfiguration.java | 21 +-- .../social/LinkedInProperties.java | 30 +++++ .../social/SocialAutoConfigurerAdapter.java | 7 +- .../social/SocialProperties.java | 6 +- .../social/TwitterAutoConfiguration.java | 23 +--- .../social/TwitterProperties.java | 30 +++++ .../thymeleaf/ThymeleafAutoConfiguration.java | 101 +------------- .../thymeleaf/ThymeleafProperties.java | 124 ++++++++++++++++++ ...ThymeleafTemplateAvailabilityProvider.java | 4 +- 14 files changed, 261 insertions(+), 182 deletions(-) create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookProperties.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInProperties.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterProperties.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java index dff2ce092b..76198f216e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java @@ -30,7 +30,6 @@ public class BatchProperties { private static final String DEFAULT_SCHEMA_LOCATION = "classpath:org/springframework/" + "batch/core/schema-@@platform@@.sql"; - private String schema = DEFAULT_SCHEMA_LOCATION; private final Initializer initializer = new Initializer(); @@ -38,7 +37,7 @@ public class BatchProperties { private final Job job = new Job(); public String getSchema() { - return schema; + return this.schema; } public void setSchema(String schema) { @@ -46,11 +45,11 @@ public class BatchProperties { } public Initializer getInitializer() { - return initializer; + return this.initializer; } public Job getJob() { - return job; + return this.job; } public static class Initializer { @@ -58,12 +57,13 @@ public class BatchProperties { private boolean enabled = true; public boolean isEnabled() { - return enabled; + return this.enabled; } public void setEnabled(boolean enabled) { this.enabled = enabled; } + } public static class Job { @@ -71,11 +71,12 @@ public class BatchProperties { private String names = ""; public String getNames() { - return names; + return this.names; } public void setNames(String names) { this.names = names; } + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java index 4a97ba26e1..d962c59c65 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java @@ -64,7 +64,12 @@ public class DeviceDelegatingViewResolverAutoConfiguration { ViewResolver delegate, int delegateOrder) { LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver( delegate); - viewResolverProperties.apply(resolver); + resolver.setNormalPrefix(this.viewResolverProperties.getNormalPrefix()); + resolver.setNormalSuffix(this.viewResolverProperties.getNormalSuffix()); + resolver.setMobilePrefix(this.viewResolverProperties.getMobilePrefix()); + resolver.setMobileSuffix(this.viewResolverProperties.getMobileSuffix()); + resolver.setTabletPrefix(this.viewResolverProperties.getTabletPrefix()); + resolver.setTabletSuffix(this.viewResolverProperties.getTabletSuffix()); resolver.setOrder(getAdjustedOrder(delegateOrder)); return resolver; } @@ -83,8 +88,7 @@ public class DeviceDelegatingViewResolverAutoConfiguration { @Configuration @EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class) @ConditionalOnMissingBean(name = "deviceDelegatingViewResolver") - @ConditionalOnProperty(value = "spring.mobile.devicedelegatingviewresolver.enabled", - match = "true", defaultMatch = false) + @ConditionalOnProperty(value = "spring.mobile.devicedelegatingviewresolver.enabled", match = "true", defaultMatch = false) protected static class DeviceDelegatingViewResolverConfiguration { @Configuration diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverProperties.java index 8a192c3037..17569efc97 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverProperties.java @@ -17,10 +17,9 @@ package org.springframework.boot.autoconfigure.mobile; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver; /** - * {@link ConfigurationProperties properties} for device view resolver. + * Properties for device view resolver. * * @author Stephane Nicoll * @since 1.2.0 @@ -41,7 +40,7 @@ public class DeviceDelegatingViewResolverProperties { private String tabletSuffix = ""; public String getNormalPrefix() { - return normalPrefix; + return this.normalPrefix; } public void setNormalPrefix(String normalPrefix) { @@ -49,7 +48,7 @@ public class DeviceDelegatingViewResolverProperties { } public String getNormalSuffix() { - return normalSuffix; + return this.normalSuffix; } public void setNormalSuffix(String normalSuffix) { @@ -57,7 +56,7 @@ public class DeviceDelegatingViewResolverProperties { } public String getMobilePrefix() { - return mobilePrefix; + return this.mobilePrefix; } public void setMobilePrefix(String mobilePrefix) { @@ -65,7 +64,7 @@ public class DeviceDelegatingViewResolverProperties { } public String getMobileSuffix() { - return mobileSuffix; + return this.mobileSuffix; } public void setMobileSuffix(String mobileSuffix) { @@ -73,7 +72,7 @@ public class DeviceDelegatingViewResolverProperties { } public String getTabletPrefix() { - return tabletPrefix; + return this.tabletPrefix; } public void setTabletPrefix(String tabletPrefix) { @@ -81,20 +80,11 @@ public class DeviceDelegatingViewResolverProperties { } public String getTabletSuffix() { - return tabletSuffix; + return this.tabletSuffix; } public void setTabletSuffix(String tabletSuffix) { this.tabletSuffix = tabletSuffix; } - public void apply(LiteDeviceDelegatingViewResolver resolver) { - resolver.setNormalPrefix(getNormalPrefix()); - resolver.setNormalSuffix(getNormalSuffix()); - resolver.setMobilePrefix(getMobilePrefix()); - resolver.setMobileSuffix(getMobileSuffix()); - resolver.setTabletPrefix(getTabletPrefix()); - resolver.setTabletSuffix(getTabletSuffix()); - } - } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java index 34e3a909ac..12316d2f8e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -64,12 +63,7 @@ public class FacebookAutoConfiguration { SocialAutoConfigurerAdapter { @Autowired - private FacebookProperties facebookProperties; - - @Override - protected SocialProperties getSocialProperties() { - return facebookProperties; - } + private FacebookProperties properties; @Bean @ConditionalOnMissingBean(Facebook.class) @@ -86,14 +80,10 @@ public class FacebookAutoConfiguration { return new GenericConnectionStatusView("facebook", "Facebook"); } - } - - @ConfigurationProperties("spring.social.facebook") - public static class FacebookProperties extends SocialProperties { - - public ConnectionFactory createConnectionFactory() { - return new FacebookConnectionFactory( - getAppId(), getAppSecret()); + @Override + protected ConnectionFactory createConnectionFactory() { + return new FacebookConnectionFactory(this.properties.getAppId(), + this.properties.getAppSecret()); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookProperties.java new file mode 100644 index 0000000000..5280fe4a26 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookProperties.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2014 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.social; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for Spring Social Facebook. + * + * @author Stephane Nicoll + * @since 1.2.0 + */ +@ConfigurationProperties("spring.social.facebook") +public class FacebookProperties extends SocialProperties { + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java index 17b5858dd2..f9fb652ead 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java @@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -63,12 +62,7 @@ public class LinkedInAutoConfiguration { SocialAutoConfigurerAdapter { @Autowired - private LinkedInProperties linkedInProperties; - - @Override - protected SocialProperties getSocialProperties() { - return linkedInProperties; - } + private LinkedInProperties properties; @Bean @ConditionalOnMissingBean(LinkedIn.class) @@ -85,16 +79,11 @@ public class LinkedInAutoConfiguration { return new GenericConnectionStatusView("linkedin", "LinkedIn"); } - } - - @ConfigurationProperties("spring.social.linkedin") - public static class LinkedInProperties extends SocialProperties { - - public ConnectionFactory createConnectionFactory() { - return new LinkedInConnectionFactory( - getAppId(), getAppSecret()); + @Override + protected ConnectionFactory createConnectionFactory() { + return new LinkedInConnectionFactory(this.properties.getAppId(), + this.properties.getAppSecret()); } - } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInProperties.java new file mode 100644 index 0000000000..c19ce5e065 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInProperties.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2014 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.social; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for Spring Social LinkedIn. + * + * @author Stephane Nicoll + * @since 1.2.0 + */ +@ConfigurationProperties("spring.social.linkedin") +public class LinkedInProperties extends SocialProperties { + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.java index bde673f1bc..0f224c2f65 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.social; import org.springframework.core.env.Environment; import org.springframework.social.config.annotation.ConnectionFactoryConfigurer; import org.springframework.social.config.annotation.SocialConfigurerAdapter; +import org.springframework.social.connect.ConnectionFactory; /** * Base class for auto-configured {@link SocialConfigurerAdapter}s. @@ -29,12 +30,12 @@ import org.springframework.social.config.annotation.SocialConfigurerAdapter; */ abstract class SocialAutoConfigurerAdapter extends SocialConfigurerAdapter { - protected abstract SocialProperties getSocialProperties(); - @Override public void addConnectionFactories(ConnectionFactoryConfigurer configurer, Environment environment) { - configurer.addConnectionFactory(getSocialProperties().createConnectionFactory()); + configurer.addConnectionFactory(createConnectionFactory()); } + protected abstract ConnectionFactory createConnectionFactory(); + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialProperties.java index 9e1a4915b1..80722633a0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialProperties.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.social; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.social.connect.ConnectionFactory; /** * Base {@link ConfigurationProperties properties} for spring social. @@ -32,7 +31,7 @@ abstract class SocialProperties { private String appSecret; public String getAppId() { - return appId; + return this.appId; } public void setAppId(String appId) { @@ -40,12 +39,11 @@ abstract class SocialProperties { } public String getAppSecret() { - return appSecret; + return this.appSecret; } public void setAppSecret(String appSecret) { this.appSecret = appSecret; } - public abstract ConnectionFactory createConnectionFactory(); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java index 0accfa99e1..fa008e891f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java @@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -64,12 +63,7 @@ public class TwitterAutoConfiguration { SocialAutoConfigurerAdapter { @Autowired - private TwitterProperties twitterProperties; - - @Override - protected SocialProperties getSocialProperties() { - return twitterProperties; - } + private TwitterProperties properties; @Bean @ConditionalOnMissingBean @@ -80,7 +74,8 @@ public class TwitterAutoConfiguration { if (connection != null) { return connection.getApi(); } - return new TwitterTemplate(twitterProperties.getAppId(), twitterProperties.getAppSecret()); + return new TwitterTemplate(this.properties.getAppId(), + this.properties.getAppSecret()); } @Bean(name = { "connect/twitterConnect", "connect/twitterConnected" }) @@ -89,14 +84,10 @@ public class TwitterAutoConfiguration { return new GenericConnectionStatusView("twitter", "Twitter"); } - } - - @ConfigurationProperties("spring.social.twitter") - public static class TwitterProperties extends SocialProperties { - - public ConnectionFactory createConnectionFactory() { - return new TwitterConnectionFactory( - getAppId(), getAppSecret()); + @Override + protected ConnectionFactory createConnectionFactory() { + return new TwitterConnectionFactory(this.properties.getAppId(), + this.properties.getAppSecret()); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterProperties.java new file mode 100644 index 0000000000..6f14ace3b5 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterProperties.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2014 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.social; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for Spring Social Twitter. + * + * @author Stephane Nicoll + * @since 1.2.0 + */ +@ConfigurationProperties("spring.social.twitter") +public class TwitterProperties extends SocialProperties { + +} 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 1783291872..34ed054361 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 @@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -57,15 +56,11 @@ import com.github.mxab.thymeleaf.extras.dataattribute.dialect.DataAttributeDiale * @author Stephane Nicoll */ @Configuration -@EnableConfigurationProperties(ThymeleafAutoConfiguration.ThymeleafProperties.class) +@EnableConfigurationProperties(ThymeleafProperties.class) @ConditionalOnClass(SpringTemplateEngine.class) @AutoConfigureAfter(WebMvcAutoConfiguration.class) public class ThymeleafAutoConfiguration { - public static final String DEFAULT_PREFIX = "classpath:/templates/"; - - public static final String DEFAULT_SUFFIX = ".html"; - @Configuration @ConditionalOnMissingBean(name = "defaultTemplateResolver") public static class DefaultTemplateResolverConfiguration { @@ -106,100 +101,6 @@ public class ThymeleafAutoConfiguration { } } - @ConfigurationProperties("spring.thymeleaf") - public static class ThymeleafProperties { - - private boolean checkTemplateLocation = true; - - private String prefix = DEFAULT_PREFIX; - - private String suffix = DEFAULT_SUFFIX; - - private String mode = "HTML5"; - - private String encoding = "UTF-8"; - - private String contentType = "text/html"; - - private boolean cache = true; - - private String[] viewNames; - - private String[] excludedViewNames; - - public boolean isCheckTemplateLocation() { - return this.checkTemplateLocation; - } - - public void setCheckTemplateLocation(boolean checkTemplateLocation) { - this.checkTemplateLocation = checkTemplateLocation; - } - - public String getPrefix() { - return this.prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - public String getSuffix() { - return this.suffix; - } - - public void setSuffix(String suffix) { - this.suffix = suffix; - } - - public String getMode() { - return this.mode; - } - - public void setMode(String mode) { - this.mode = mode; - } - - public String getEncoding() { - return this.encoding; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public String getContentType() { - return this.contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public boolean isCache() { - return this.cache; - } - - public void setCache(boolean cache) { - this.cache = cache; - } - - public String[] getExcludedViewNames() { - return this.excludedViewNames; - } - - public void setExcludedViewNames(String[] excludedViewNames) { - this.excludedViewNames = excludedViewNames; - } - - public String[] getViewNames() { - return this.viewNames; - } - - public void setViewNames(String[] viewNames) { - this.viewNames = viewNames; - } - } - @Configuration @ConditionalOnMissingBean(SpringTemplateEngine.class) protected static class ThymeleafDefaultConfiguration { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java new file mode 100644 index 0000000000..240caf5210 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java @@ -0,0 +1,124 @@ +/* + * Copyright 2012-2014 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.thymeleaf; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for Thymeleaf. + * + * @author Stephane Nicoll + * @since 1.2.0 + */ +@ConfigurationProperties("spring.thymeleaf") +public class ThymeleafProperties { + + public static final String DEFAULT_PREFIX = "classpath:/templates/"; + + public static final String DEFAULT_SUFFIX = ".html"; + + private boolean checkTemplateLocation = true; + + private String prefix = DEFAULT_PREFIX; + + private String suffix = DEFAULT_SUFFIX; + + private String mode = "HTML5"; + + private String encoding = "UTF-8"; + + private String contentType = "text/html"; + + private boolean cache = true; + + private String[] viewNames; + + private String[] excludedViewNames; + + public boolean isCheckTemplateLocation() { + return this.checkTemplateLocation; + } + + public void setCheckTemplateLocation(boolean checkTemplateLocation) { + this.checkTemplateLocation = checkTemplateLocation; + } + + public String getPrefix() { + return this.prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return this.suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + public String getMode() { + return this.mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getEncoding() { + return this.encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public String getContentType() { + return this.contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public boolean isCache() { + return this.cache; + } + + public void setCache(boolean cache) { + this.cache = cache; + } + + public String[] getExcludedViewNames() { + return this.excludedViewNames; + } + + public void setExcludedViewNames(String[] excludedViewNames) { + this.excludedViewNames = excludedViewNames; + } + + public String[] getViewNames() { + return this.viewNames; + } + + public void setViewNames(String[] viewNames) { + this.viewNames = viewNames; + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java index 4ed790ada3..8797f0032b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java @@ -37,9 +37,9 @@ public class ThymeleafTemplateAvailabilityProvider implements if (ClassUtils.isPresent("org.thymeleaf.spring4.SpringTemplateEngine", classLoader)) { String prefix = environment.getProperty("spring.thymeleaf.prefix", - ThymeleafAutoConfiguration.DEFAULT_PREFIX); + ThymeleafProperties.DEFAULT_PREFIX); String suffix = environment.getProperty("spring.thymeleaf.suffix", - ThymeleafAutoConfiguration.DEFAULT_SUFFIX); + ThymeleafProperties.DEFAULT_SUFFIX); return resourceLoader.getResource(prefix + view + suffix).exists(); }