Browse Source

Make Tiles 3 the default implementation in spring-webmvc

Move spring-webmvc-tiles3 content to spring-webmvc, and
create a spring-webmvc-tiles2 module with Tiles 2 support.

Its allows View Resolution to configure Tiles 3 instead of Tiles 2.

Issue: SPR-7093
pull/589/merge
Sebastien Deleuze 11 years ago committed by Rossen Stoyanchev
parent
commit
a26b1ef8d9
  1. 34
      build.gradle
  2. 2
      settings.gradle
  3. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/AbstractSpringPreparerFactory.java
  4. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SimpleSpringPreparerFactory.java
  5. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringBeanPreparerFactory.java
  6. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringLocaleResolver.java
  7. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringWildcardServletTilesApplicationContext.java
  8. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java
  9. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesView.java
  10. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesViewResolver.java
  11. 0
      spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/package-info.java
  12. 0
      spring-webmvc-tiles2/src/test/java/org/springframework/web/servlet/view/tiles2/TilesConfigurerTests.java
  13. 1
      spring-webmvc-tiles2/src/test/resources/jasperreports.properties
  14. 8
      spring-webmvc-tiles2/src/test/resources/log4j.properties
  15. 0
      spring-webmvc-tiles2/src/test/resources/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml
  16. 24
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java
  17. 1
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/AbstractSpringPreparerFactory.java
  18. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java
  19. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringBeanPreparerFactory.java
  20. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringLocaleResolver.java
  21. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java
  22. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java
  23. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesView.java
  24. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesViewResolver.java
  25. 0
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/package-info.java
  26. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
  27. 0
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java
  28. 0
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java
  29. 0
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java
  30. 11
      spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-resolvers.xml
  31. 0
      spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/tiles/tiles1.xml
  32. 20
      spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/tiles/tiles2.xml
  33. 0
      spring-webmvc/src/test/resources/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml

34
build.gradle

@ -781,22 +781,22 @@ project("spring-webmvc") { @@ -781,22 +781,22 @@ project("spring-webmvc") {
}
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
optional("com.rometools:rome:1.5.0")
optional("org.apache.tiles:tiles-api:${tiles2Version}")
optional("org.apache.tiles:tiles-core:${tiles2Version}") {
optional("javax.el:javax.el-api:2.2.5")
optional("org.apache.tiles:tiles-api:${tiles3Version}")
optional("org.apache.tiles:tiles-core:${tiles3Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-servlet:${tiles2Version}") {
optional("org.apache.tiles:tiles-servlet:${tiles3Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-jsp:${tiles2Version}") {
optional("org.apache.tiles:tiles-jsp:${tiles3Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-el:${tiles2Version}") {
optional("org.apache.tiles:tiles-el:${tiles3Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-extras:${tiles2Version}") {
optional("org.apache.tiles:tiles-extras:${tiles3Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
exclude group: "org.apache.velocity", module: "velocity-tools"
exclude group: "org.springframework", module: "spring-web"
}
testCompile(project(":spring-aop"))
@ -829,8 +829,8 @@ project("spring-webmvc") { @@ -829,8 +829,8 @@ project("spring-webmvc") {
sourceSets.main.resources.srcDirs += "src/main/java"
}
project("spring-webmvc-tiles3") {
description = "Spring Framework Tiles3 Integration"
project("spring-webmvc-tiles2") {
description = "Spring Framework Tiles2 Integration"
merge.into = project(":spring-webmvc")
dependencies {
@ -839,22 +839,22 @@ project("spring-webmvc-tiles3") { @@ -839,22 +839,22 @@ project("spring-webmvc-tiles3") {
provided("javax.servlet:javax.servlet-api:3.0.1")
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
optional("javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1")
optional("javax.el:javax.el-api:2.2.5")
optional("org.apache.tiles:tiles-api:${tiles3Version}")
optional("org.apache.tiles:tiles-core:${tiles3Version}") {
optional("org.apache.tiles:tiles-api:${tiles2Version}")
optional("org.apache.tiles:tiles-core:${tiles2Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-servlet:${tiles3Version}") {
optional("org.apache.tiles:tiles-servlet:${tiles2Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-jsp:${tiles3Version}") {
optional("org.apache.tiles:tiles-jsp:${tiles2Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-el:${tiles3Version}") {
optional("org.apache.tiles:tiles-el:${tiles2Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-extras:${tiles3Version}") {
optional("org.apache.tiles:tiles-extras:${tiles2Version}") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
exclude group: "org.apache.velocity", module: "velocity-tools"
exclude group: "org.springframework", module: "spring-web"
}
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
@ -910,7 +910,7 @@ project("spring-test") { @@ -910,7 +910,7 @@ project("spring-test") {
optional("xmlunit:xmlunit:1.5")
testCompile(project(":spring-context-support"))
testCompile(project(":spring-oxm"))
testCompile(project(":spring-webmvc-tiles3"))
testCompile(project(":spring-webmvc-tiles2"))
testCompile("javax.mail:javax.mail-api:1.5.2")
testCompile("javax.ejb:ejb-api:3.0")
testCompile("org.hibernate:hibernate-core:${hibernate4Version}")

2
settings.gradle

@ -21,7 +21,7 @@ include "spring-tx" @@ -21,7 +21,7 @@ include "spring-tx"
include "spring-web"
include "spring-webmvc"
include "spring-webmvc-portlet"
include "spring-webmvc-tiles3"
include "spring-webmvc-tiles2"
include "spring-websocket"
include "spring-framework-bom"

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/AbstractSpringPreparerFactory.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/AbstractSpringPreparerFactory.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/SimpleSpringPreparerFactory.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SimpleSpringPreparerFactory.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/SpringBeanPreparerFactory.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringBeanPreparerFactory.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/SpringLocaleResolver.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringLocaleResolver.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/SpringWildcardServletTilesApplicationContext.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/SpringWildcardServletTilesApplicationContext.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesView.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesView.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesViewResolver.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/TilesViewResolver.java

0
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/package-info.java → spring-webmvc-tiles2/src/main/java/org/springframework/web/servlet/view/tiles2/package-info.java

0
spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles2/TilesConfigurerTests.java → spring-webmvc-tiles2/src/test/java/org/springframework/web/servlet/view/tiles2/TilesConfigurerTests.java

1
spring-webmvc-tiles2/src/test/resources/jasperreports.properties

@ -0,0 +1 @@ @@ -0,0 +1 @@
net.sf.jasperreports.awt.ignore.missing.font=true

8
spring-webmvc-tiles3/src/test/resources/log4j.properties → spring-webmvc-tiles2/src/test/resources/log4j.properties

@ -2,7 +2,9 @@ log4j.appender.console=org.apache.log4j.ConsoleAppender @@ -2,7 +2,9 @@ log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%c] - %m%n
log4j.rootCategory=INFO, console
log4j.logger.org.springframework.web=DEBUG
log4j.rootCategory=WARN, console
log4j.logger.org.springframework.beans=WARN
log4j.logger.org.springframework.convert=DEBUG
#log4j.logger.org.springframework.web.servlet=TRACE
#log4j.logger.org.springframework.web.servlet.view.tiles3=TRACE

0
spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml → spring-webmvc-tiles2/src/test/resources/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml

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

@ -16,9 +16,9 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; @@ -16,9 +16,9 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import org.springframework.web.servlet.view.tiles2.TilesConfigurer;
import org.springframework.web.servlet.view.tiles2.TilesView;
import org.springframework.web.servlet.view.tiles2.TilesViewResolver;
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesView;
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
import org.w3c.dom.Element;
@ -26,10 +26,10 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { @@ -26,10 +26,10 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
private static final String INTERNAL_VIEW_RESOLVER_BEAN_NAME =
"org.springframework.web.servlet.view.InternalResourceViewResolver";
private static final String TILES2_VIEW_RESOLVER_BEAN_NAME =
"org.springframework.web.servlet.view.tiles2.TilesViewResolver";
private static final String TILES2_CONFIGURER_BEAN_NAME =
"org.springframework.web.servlet.view.tiles2.TilesConfigurer";
private static final String TILES3_VIEW_RESOLVER_BEAN_NAME =
"org.springframework.web.servlet.view.tiles3.TilesViewResolver";
private static final String TILES3_CONFIGURER_BEAN_NAME =
"org.springframework.web.servlet.view.tiles3.TilesConfigurer";
private static final String BEANNAME_VIEW_RESOLVER_BEAN_NAME =
"org.springframework.web.servlet.view.BeanNameViewResolver";
private static final String FREEMARKER_CONFIGURER_BEAN_NAME =
@ -81,7 +81,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { @@ -81,7 +81,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
}
private void registerBean(String beanName,Map<String,Object> propertyMap,Class beanClass ){
private void registerBean(String beanName,Map<String,Object> propertyMap,Class<?> beanClass ){
RootBeanDefinition beanDef = new RootBeanDefinition(beanClass);
beanDef.setSource(source);
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@ -125,20 +125,20 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { @@ -125,20 +125,20 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
}
private void registerTilesConfigurerBean(ParserContext parserContext,Element viewResolverElement) {
if (!parserContext.getRegistry().containsBeanDefinition(TILES2_CONFIGURER_BEAN_NAME)) {
if (!parserContext.getRegistry().containsBeanDefinition(TILES3_CONFIGURER_BEAN_NAME)) {
Map<String, Object> propertyMap= new HashMap<String, Object>();
propertyMap.put("definitions", viewResolverElement.getAttribute("definitions"));
registerBean(TILES2_CONFIGURER_BEAN_NAME, propertyMap, TilesConfigurer.class);
registerBean(TILES3_CONFIGURER_BEAN_NAME, propertyMap, TilesConfigurer.class);
}
}
private void registerTilesViewResolverBean(ParserContext parserContext, Element viewResolverElement) {
if (!parserContext.getRegistry().containsBeanDefinition(TILES2_VIEW_RESOLVER_BEAN_NAME)) {
if (!parserContext.getRegistry().containsBeanDefinition(TILES3_VIEW_RESOLVER_BEAN_NAME)) {
Map<String, Object> propertyMap= new HashMap<String, Object>();
propertyMap.put("viewClass", TilesView.class);
propertyMap.put("order", 1);
registerBean(TILES2_VIEW_RESOLVER_BEAN_NAME, propertyMap, TilesViewResolver.class);
registerBean(TILES3_VIEW_RESOLVER_BEAN_NAME, propertyMap, TilesViewResolver.class);
}
}
private void registerInternalResourceViewResolverBean(ParserContext parserContext, Element viewResolverElement) {

1
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/AbstractSpringPreparerFactory.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/AbstractSpringPreparerFactory.java

@ -22,7 +22,6 @@ import org.apache.tiles.preparer.factory.PreparerFactory; @@ -22,7 +22,6 @@ import org.apache.tiles.preparer.factory.PreparerFactory;
import org.apache.tiles.request.Request;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory;
/**
* Abstract implementation of the Tiles3 {@link org.apache.tiles.preparer.PreparerFactory}

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringBeanPreparerFactory.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringBeanPreparerFactory.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringLocaleResolver.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringLocaleResolver.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesView.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesView.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesViewResolver.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesViewResolver.java

0
spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/package-info.java → spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/package-info.java

4
spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java

@ -89,8 +89,8 @@ import org.springframework.web.servlet.view.InternalResourceView; @@ -89,8 +89,8 @@ import org.springframework.web.servlet.view.InternalResourceView;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import org.springframework.web.servlet.view.tiles2.TilesConfigurer;
import org.springframework.web.servlet.view.tiles2.TilesViewResolver;
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
import static org.junit.Assert.*;

0
spring-webmvc-tiles3/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java → spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java

0
spring-webmvc-tiles3/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java → spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java

0
spring-webmvc-tiles3/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java → spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java

11
spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-resolvers.xml

@ -5,13 +5,12 @@ @@ -5,13 +5,12 @@
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<mvc:view-resolvers>
<mvc:jsp prefix="/WEB-INF/" suffix=".jsp" />
<mvc:view-resolvers>
<mvc:jsp prefix="/WEB-INF/" suffix=".jsp" />
<mvc:bean-name />
<mvc:tiles definitions="/tiles.xml" />
<mvc:freemarker prefix="" suffix=".ftl" templateLoaderPath="/WEB-INF/ftl/" />
</mvc:view-resolvers>
<mvc:tiles definitions="/org/springframework/web/servlet/resource/tiles/tiles1.xml,/org/springframework/web/servlet/resource/tiles/tiles2.xml" />
<mvc:freemarker prefix="" suffix=".ftl" templateLoaderPath="/" />
</mvc:view-resolvers>
</beans>

0
spring-webmvc/src/test/resources/tiles.xml → spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/tiles/tiles1.xml

20
spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/tiles/tiles2.xml

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="base.definition"
template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>
<definition name="contact" extends="base.definition">
<put-attribute name="title" value="Contact Manager" />
<put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>
</tiles-definitions>

0
spring-webmvc-tiles3/src/test/resources/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml → spring-webmvc/src/test/resources/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml

Loading…
Cancel
Save