Deprecate Velocity support
Issue: SPR-13235
This commit is contained in:
@@ -39,7 +39,6 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
|
||||
import org.springframework.web.servlet.view.script.ScriptTemplateViewResolver;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
|
||||
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||
|
||||
/**
|
||||
* Parse the {@code view-resolvers} MVC namespace element and register
|
||||
@@ -69,6 +68,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
|
||||
public static final String VIEW_RESOLVER_BEAN_NAME = "mvcViewResolver";
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public BeanDefinition parse(Element element, ParserContext context) {
|
||||
Object source = context.extractSource(element);
|
||||
context.pushContainingComponent(new CompositeComponentDefinition(element.getTagName(), source));
|
||||
@@ -100,7 +100,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
|
||||
addUrlBasedViewResolverProperties(resolverElement, resolverBeanDef);
|
||||
}
|
||||
else if ("velocity".equals(name)) {
|
||||
resolverBeanDef = new RootBeanDefinition(VelocityViewResolver.class);
|
||||
resolverBeanDef = new RootBeanDefinition(org.springframework.web.servlet.view.velocity.VelocityViewResolver.class);
|
||||
resolverBeanDef.getPropertyValues().add("suffix", ".vm");
|
||||
addUrlBasedViewResolverProperties(resolverElement, resolverBeanDef);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ import org.springframework.web.servlet.view.script.ScriptTemplateConfigurer;
|
||||
import org.springframework.web.servlet.view.script.ScriptTemplateViewResolver;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
|
||||
import org.springframework.web.servlet.view.velocity.VelocityConfigurer;
|
||||
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||
|
||||
/**
|
||||
* Assist with the configuration of a chain of
|
||||
@@ -86,10 +84,8 @@ public class ViewResolverRegistry {
|
||||
* Enable use of a {@link ContentNegotiatingViewResolver} to front all other
|
||||
* configured view resolvers and select among all selected Views based on
|
||||
* media types requested by the client (e.g. in the Accept header).
|
||||
*
|
||||
* <p>If invoked multiple times the provided default views will be added to
|
||||
* any other default views that may have been configured already.
|
||||
*
|
||||
* @see ContentNegotiatingViewResolver#setDefaultViews
|
||||
*/
|
||||
public void enableContentNegotiation(View... defaultViews) {
|
||||
@@ -100,7 +96,6 @@ public class ViewResolverRegistry {
|
||||
* Enable use of a {@link ContentNegotiatingViewResolver} to front all other
|
||||
* configured view resolvers and select among all selected Views based on
|
||||
* media types requested by the client (e.g. in the Accept header).
|
||||
*
|
||||
* <p>If invoked multiple times the provided default views will be added to
|
||||
* any other default views that may have been configured already.
|
||||
*
|
||||
@@ -112,9 +107,8 @@ public class ViewResolverRegistry {
|
||||
}
|
||||
|
||||
private void initContentNegotiatingViewResolver(View[] defaultViews) {
|
||||
|
||||
// ContentNegotiatingResolver in the registry: elevate its precedence!
|
||||
this.order = (this.order == null ? Ordered.HIGHEST_PRECEDENCE : this.order);
|
||||
this.order = (this.order != null ? this.order : Ordered.HIGHEST_PRECEDENCE);
|
||||
|
||||
if (this.contentNegotiatingResolver != null) {
|
||||
if (!ObjectUtils.isEmpty(defaultViews)) {
|
||||
@@ -136,7 +130,6 @@ public class ViewResolverRegistry {
|
||||
/**
|
||||
* Register JSP view resolver using a default view name prefix of "/WEB-INF/"
|
||||
* and a default suffix of ".jsp".
|
||||
*
|
||||
* <p>When this method is invoked more than once, each call will register a
|
||||
* new ViewResolver instance. Note that since it's not easy to determine
|
||||
* if a JSP exists without forwarding to it, using multiple JSP-based view
|
||||
@@ -149,7 +142,6 @@ public class ViewResolverRegistry {
|
||||
|
||||
/**
|
||||
* Register JSP view resolver with the specified prefix and suffix.
|
||||
*
|
||||
* <p>When this method is invoked more than once, each call will register a
|
||||
* new ViewResolver instance. Note that since it's not easy to determine
|
||||
* if a JSP exists without forwarding to it, using multiple JSP-based view
|
||||
@@ -166,7 +158,6 @@ public class ViewResolverRegistry {
|
||||
|
||||
/**
|
||||
* Register Tiles 3.x view resolver.
|
||||
*
|
||||
* <p><strong>Note</strong> that you must also configure Tiles by adding a
|
||||
* {@link org.springframework.web.servlet.view.tiles3.TilesConfigurer} bean.
|
||||
*/
|
||||
@@ -184,7 +175,6 @@ public class ViewResolverRegistry {
|
||||
/**
|
||||
* Register a FreeMarker view resolver with an empty default view name
|
||||
* prefix and a default suffix of ".ftl".
|
||||
*
|
||||
* <p><strong>Note</strong> that you must also configure FreeMarker by adding a
|
||||
* {@link org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer} bean.
|
||||
*/
|
||||
@@ -203,12 +193,13 @@ public class ViewResolverRegistry {
|
||||
/**
|
||||
* Register Velocity view resolver with an empty default view name
|
||||
* prefix and a default suffix of ".vm".
|
||||
*
|
||||
* <p><strong>Note</strong> that you must also configure Velocity by adding a
|
||||
* {@link org.springframework.web.servlet.view.velocity.VelocityConfigurer} bean.
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public UrlBasedViewResolverRegistration velocity() {
|
||||
if (this.applicationContext != null && !hasBeanOfType(VelocityConfigurer.class)) {
|
||||
if (this.applicationContext != null && !hasBeanOfType(org.springframework.web.servlet.view.velocity.VelocityConfigurer.class)) {
|
||||
throw new BeanInitializationException("In addition to a Velocity view resolver " +
|
||||
"there must also be a single VelocityConfig bean in this web application context " +
|
||||
"(or its parent): VelocityConfigurer is the usual implementation. " +
|
||||
@@ -313,22 +304,23 @@ public class ViewResolverRegistry {
|
||||
|
||||
private static class TilesRegistration extends UrlBasedViewResolverRegistration {
|
||||
|
||||
private TilesRegistration() {
|
||||
public TilesRegistration() {
|
||||
super(new TilesViewResolver());
|
||||
}
|
||||
}
|
||||
|
||||
private static class VelocityRegistration extends UrlBasedViewResolverRegistration {
|
||||
|
||||
private VelocityRegistration() {
|
||||
super(new VelocityViewResolver());
|
||||
@SuppressWarnings("deprecation")
|
||||
public VelocityRegistration() {
|
||||
super(new org.springframework.web.servlet.view.velocity.VelocityViewResolver());
|
||||
getViewResolver().setSuffix(".vm");
|
||||
}
|
||||
}
|
||||
|
||||
private static class FreeMarkerRegistration extends UrlBasedViewResolverRegistration {
|
||||
|
||||
private FreeMarkerRegistration() {
|
||||
public FreeMarkerRegistration() {
|
||||
super(new FreeMarkerViewResolver());
|
||||
getViewResolver().setSuffix(".ftl");
|
||||
}
|
||||
@@ -336,7 +328,7 @@ public class ViewResolverRegistry {
|
||||
|
||||
private static class GroovyMarkupRegistration extends UrlBasedViewResolverRegistration {
|
||||
|
||||
private GroovyMarkupRegistration() {
|
||||
public GroovyMarkupRegistration() {
|
||||
super(new GroovyMarkupViewResolver());
|
||||
getViewResolver().setSuffix(".tpl");
|
||||
}
|
||||
@@ -344,7 +336,7 @@ public class ViewResolverRegistry {
|
||||
|
||||
private static class ScriptRegistration extends UrlBasedViewResolverRegistration {
|
||||
|
||||
private ScriptRegistration() {
|
||||
public ScriptRegistration() {
|
||||
super(new ScriptTemplateViewResolver());
|
||||
getViewResolver();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ import org.apache.velocity.app.VelocityEngine;
|
||||
* @author Rod Johnson
|
||||
* @see VelocityConfigurer
|
||||
* @see VelocityView
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public interface VelocityConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.ui.velocity.VelocityEngineFactory;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
|
||||
/**
|
||||
@@ -69,8 +68,10 @@ import org.springframework.web.context.ServletContextAware;
|
||||
* @see #setResourceLoaderPath
|
||||
* @see #setVelocityEngine
|
||||
* @see VelocityView
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
public class VelocityConfigurer extends VelocityEngineFactory
|
||||
@Deprecated
|
||||
public class VelocityConfigurer extends org.springframework.ui.velocity.VelocityEngineFactory
|
||||
implements VelocityConfig, InitializingBean, ResourceLoaderAware, ServletContextAware {
|
||||
|
||||
/** the name of the resource loader for Spring's bind macros */
|
||||
|
||||
@@ -50,7 +50,9 @@ import org.springframework.core.NestedIOException;
|
||||
* @see #setLayoutUrl
|
||||
* @see #setLayoutKey
|
||||
* @see #setScreenContentKey
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityLayoutView extends VelocityToolboxView {
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,9 @@ import org.springframework.web.servlet.view.AbstractUrlBasedView;
|
||||
* @see #setLayoutUrl
|
||||
* @see #setLayoutKey
|
||||
* @see #setScreenContentKey
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityLayoutViewResolver extends VelocityViewResolver {
|
||||
|
||||
private String layoutUrl;
|
||||
|
||||
@@ -62,7 +62,9 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @see #initTool
|
||||
* @see org.apache.velocity.tools.view.context.ViewContext
|
||||
* @see org.apache.velocity.tools.view.context.ChainedContext
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityToolboxView extends VelocityView {
|
||||
|
||||
private String toolboxConfigLocation;
|
||||
|
||||
@@ -83,7 +83,9 @@ import org.springframework.web.util.NestedServletException;
|
||||
* @see #setVelocityEngine
|
||||
* @see VelocityConfig
|
||||
* @see VelocityConfigurer
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityView extends AbstractTemplateView {
|
||||
|
||||
private Map<String, Class<?>> toolAttributes;
|
||||
|
||||
@@ -40,7 +40,9 @@ import org.springframework.web.servlet.view.AbstractUrlBasedView;
|
||||
* @see #setDateToolAttribute
|
||||
* @see #setNumberToolAttribute
|
||||
* @see VelocityView
|
||||
* @deprecated as of Spring 4.3, in favor of FreeMarker
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityViewResolver extends AbstractTemplateViewResolver {
|
||||
|
||||
private String dateToolAttribute;
|
||||
|
||||
Reference in New Issue
Block a user