Harmonize view resolver properties
Move shared properties to avoid duplication in GroovyProperties Fixes gh-1835
This commit is contained in:
parent
1a3b0309b3
commit
6d9abdc8ca
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.groovy.template;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.AbstractBasicTemplateViewResolverProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
|
|
@ -28,7 +29,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.groovy.template", ignoreUnknownFields = false)
|
||||
public class GroovyTemplateProperties {
|
||||
public class GroovyTemplateProperties extends AbstractBasicTemplateViewResolverProperties {
|
||||
|
||||
public static final String DEFAULT_PREFIX = "classpath:/templates/";
|
||||
|
||||
|
|
@ -38,60 +39,8 @@ public class GroovyTemplateProperties {
|
|||
|
||||
private String suffix = DEFAULT_SUFFIX;
|
||||
|
||||
private boolean cache;
|
||||
|
||||
private String contentType = "text/html";
|
||||
|
||||
private String charSet = "UTF-8";
|
||||
|
||||
private String[] viewNames;
|
||||
|
||||
private boolean checkTemplateLocation = false;
|
||||
|
||||
private Map<String, Object> configuration = new HashMap<String, Object>();
|
||||
|
||||
public void setCheckTemplateLocation(boolean checkTemplateLocation) {
|
||||
this.checkTemplateLocation = checkTemplateLocation;
|
||||
}
|
||||
|
||||
public boolean isCheckTemplateLocation() {
|
||||
return this.checkTemplateLocation;
|
||||
}
|
||||
|
||||
public String[] getViewNames() {
|
||||
return this.viewNames;
|
||||
}
|
||||
|
||||
public void setViewNames(String[] viewNames) {
|
||||
this.viewNames = viewNames;
|
||||
}
|
||||
|
||||
public boolean isCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public void setCache(boolean cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return this.contentType
|
||||
+ (this.contentType.contains(";charset=") ? "" : ";charset="
|
||||
+ this.charSet);
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getCharSet() {
|
||||
return this.charSet;
|
||||
}
|
||||
|
||||
public void setCharSet(String charSet) {
|
||||
this.charSet = charSet;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* 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.template;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Basic base {@link ConfigurationProperties} class for view resolvers.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public abstract class AbstractBasicTemplateViewResolverProperties {
|
||||
|
||||
private boolean cache;
|
||||
|
||||
private String contentType = "text/html";
|
||||
|
||||
private String charset = "UTF-8";
|
||||
|
||||
private String[] viewNames;
|
||||
|
||||
private boolean checkTemplateLocation = true;
|
||||
|
||||
public void setCheckTemplateLocation(boolean checkTemplateLocation) {
|
||||
this.checkTemplateLocation = checkTemplateLocation;
|
||||
}
|
||||
|
||||
public boolean isCheckTemplateLocation() {
|
||||
return this.checkTemplateLocation;
|
||||
}
|
||||
|
||||
public String[] getViewNames() {
|
||||
return this.viewNames;
|
||||
}
|
||||
|
||||
public void setViewNames(String[] viewNames) {
|
||||
this.viewNames = viewNames;
|
||||
}
|
||||
|
||||
public boolean isCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public void setCache(boolean cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return this.contentType
|
||||
+ (this.contentType.contains(";charset=") ? "" : ";charset="
|
||||
+ this.charset);
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.2.0 in favor of {@link #getCharset()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCharSet() {
|
||||
return getCharset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.2.0 in favor of {@link #setCharset(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCharSet(String charSet) {
|
||||
setCharset(charSet);
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return this.charset;
|
||||
}
|
||||
|
||||
public void setCharset(String charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,22 +28,12 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
|||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public abstract class AbstractTemplateViewResolverProperties {
|
||||
public abstract class AbstractTemplateViewResolverProperties extends AbstractBasicTemplateViewResolverProperties {
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private boolean cache;
|
||||
|
||||
private String contentType = "text/html";
|
||||
|
||||
private String charset = "UTF-8";
|
||||
|
||||
private String[] viewNames;
|
||||
|
||||
private boolean checkTemplateLocation = true;
|
||||
|
||||
private String requestContextAttribute;
|
||||
|
||||
private boolean exposeRequestAttributes = false;
|
||||
|
|
@ -60,64 +50,6 @@ public abstract class AbstractTemplateViewResolverProperties {
|
|||
this.suffix = defaultSuffix;
|
||||
}
|
||||
|
||||
public void setCheckTemplateLocation(boolean checkTemplateLocation) {
|
||||
this.checkTemplateLocation = checkTemplateLocation;
|
||||
}
|
||||
|
||||
public boolean isCheckTemplateLocation() {
|
||||
return this.checkTemplateLocation;
|
||||
}
|
||||
|
||||
public String[] getViewNames() {
|
||||
return this.viewNames;
|
||||
}
|
||||
|
||||
public void setViewNames(String[] viewNames) {
|
||||
this.viewNames = viewNames;
|
||||
}
|
||||
|
||||
public boolean isCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public void setCache(boolean cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return this.contentType
|
||||
+ (this.contentType.contains(";charset=") ? "" : ";charset="
|
||||
+ this.charset);
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.2.0 in favor of {@link #getCharset()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCharSet() {
|
||||
return getCharset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.2.0 in favor of {@link #setCharset(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCharSet(String charSet) {
|
||||
setCharset(charSet);
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return this.charset;
|
||||
}
|
||||
|
||||
public void setCharset(String charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue