Browse Source

Deprecate Velocity support

Issue: SPR-13235
pull/937/head
Juergen Hoeller 9 years ago
parent
commit
a2a9c47e59
  1. 2
      spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java
  2. 2
      spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java
  3. 2
      spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java
  4. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java
  5. 30
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java
  6. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityConfig.java
  7. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityConfigurer.java
  8. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java
  9. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutViewResolver.java
  10. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java
  11. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java
  12. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityViewResolver.java
  13. 28
      spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.3.xsd

2
spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java

@ -69,7 +69,9 @@ import org.springframework.util.StringUtils; @@ -69,7 +69,9 @@ import org.springframework.util.StringUtils;
* @see VelocityEngineFactoryBean
* @see org.springframework.web.servlet.view.velocity.VelocityConfigurer
* @see org.apache.velocity.app.VelocityEngine
* @deprecated as of Spring 4.3, in favor of FreeMarker
*/
@Deprecated
public class VelocityEngineFactory {
protected final Log logger = LogFactory.getLog(getClass());

2
spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java

@ -46,7 +46,9 @@ import org.springframework.context.ResourceLoaderAware; @@ -46,7 +46,9 @@ import org.springframework.context.ResourceLoaderAware;
* @see #setVelocityProperties
* @see #setResourceLoaderPath
* @see org.springframework.web.servlet.view.velocity.VelocityConfigurer
* @deprecated as of Spring 4.3, in favor of FreeMarker
*/
@Deprecated
public class VelocityEngineFactoryBean extends VelocityEngineFactory
implements FactoryBean<VelocityEngine>, InitializingBean, ResourceLoaderAware {

2
spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java

@ -30,7 +30,9 @@ import org.apache.velocity.exception.VelocityException; @@ -30,7 +30,9 @@ import org.apache.velocity.exception.VelocityException;
*
* @author Juergen Hoeller
* @since 22.01.2004
* @deprecated as of Spring 4.3, in favor of FreeMarker
*/
@Deprecated
public abstract class VelocityEngineUtils {
/**

4
spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java

@ -39,7 +39,6 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; @@ -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 { @@ -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 { @@ -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);
}

30
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java

@ -41,8 +41,6 @@ import org.springframework.web.servlet.view.script.ScriptTemplateConfigurer; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -344,7 +336,7 @@ public class ViewResolverRegistry {
private static class ScriptRegistration extends UrlBasedViewResolverRegistration {
private ScriptRegistration() {
public ScriptRegistration() {
super(new ScriptTemplateViewResolver());
getViewResolver();
}

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityConfig.java

@ -26,7 +26,9 @@ import org.apache.velocity.app.VelocityEngine; @@ -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 {
/**

5
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityConfigurer.java

@ -25,7 +25,6 @@ import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; @@ -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; @@ -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 */

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java

@ -50,7 +50,9 @@ import org.springframework.core.NestedIOException; @@ -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 {
/**

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutViewResolver.java

@ -31,7 +31,9 @@ import org.springframework.web.servlet.view.AbstractUrlBasedView; @@ -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;

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java

@ -62,7 +62,9 @@ import org.springframework.util.ReflectionUtils; @@ -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;

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java

@ -83,7 +83,9 @@ import org.springframework.web.util.NestedServletException; @@ -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;

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/VelocityViewResolver.java

@ -40,7 +40,9 @@ import org.springframework.web.servlet.view.AbstractUrlBasedView; @@ -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;

28
spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.3.xsd

@ -1022,16 +1022,6 @@ @@ -1022,16 +1022,6 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="velocity" type="urlViewResolverType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Register a VelocityViewResolver.
By default, ".vm" is configured as a view name suffix.
To configure Velocity you must also add a top-level <mvc:velocity-configurer> element
or declare a VelocityConfigurer bean.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="groovy" type="urlViewResolverType">
<xsd:annotation>
<xsd:documentation><![CDATA[
@ -1170,24 +1160,6 @@ @@ -1170,24 +1160,6 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="velocity-configurer">
<xsd:annotation>
<xsd:documentation><![CDATA[
Configure Velocity for view resolution by registering a VelocityConfigurer bean.
This is a shortcut alternative to declaring a VelocityConfigurer bean directly.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="resource-loader-path" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The Velocity resource loader path via a Spring resource location.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="groovy-configurer">
<xsd:annotation>
<xsd:documentation><![CDATA[

Loading…
Cancel
Save