Polishing (along with the Tiles 2.2.2 upgrade in the Spring 4.0 line)
Issue: SPR-11285
This commit is contained in:
parent
dbfe68a6dc
commit
0606c98277
25
build.gradle
25
build.gradle
|
|
@ -565,22 +565,22 @@ project("spring-webmvc") {
|
|||
compile(project(":spring-context"))
|
||||
optional(project(":spring-context-support")) // for Velocity support
|
||||
optional(project(":spring-oxm")) // for MarshallingView
|
||||
optional("org.apache.tiles:tiles-api:2.1.2")
|
||||
optional("org.apache.tiles:tiles-core:2.1.2")
|
||||
optional("org.apache.tiles:tiles-jsp:2.1.2")
|
||||
optional("org.apache.tiles:tiles-servlet:2.1.2")
|
||||
optional("net.sourceforge.jexcelapi:jxl:2.6.3")
|
||||
optional("org.apache.poi:poi:3.0.2-FINAL")
|
||||
optional("com.lowagie:itext:2.1.7")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.4.2")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.0.1")
|
||||
optional("jasperreports:jasperreports:2.0.5") {
|
||||
exclude group: "xml-apis", module: "xml-apis"
|
||||
}
|
||||
optional("rome:rome:1.0")
|
||||
optional("com.lowagie:itext:2.1.7")
|
||||
optional("net.sourceforge.jexcelapi:jxl:2.6.3")
|
||||
optional("org.apache.poi:poi:3.0.2-FINAL")
|
||||
optional("velocity:velocity:1.5")
|
||||
optional("velocity-tools:velocity-tools-view:1.4")
|
||||
optional("org.freemarker:freemarker:2.3.19")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.4.2")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.0.1")
|
||||
optional("org.apache.tiles:tiles-api:2.1.2")
|
||||
optional("org.apache.tiles:tiles-core:2.1.2")
|
||||
optional("org.apache.tiles:tiles-jsp:2.1.2")
|
||||
optional("org.apache.tiles:tiles-servlet:2.1.2")
|
||||
provided("javax.servlet:jstl:1.2")
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
provided("javax.servlet.jsp:jsp-api:2.1")
|
||||
|
|
@ -634,12 +634,13 @@ project("spring-webmvc-tiles3") {
|
|||
optional("org.apache.tiles:tiles-jsp:3.0.1") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tiles:tiles-extras:3.0.1") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tiles:tiles-el:3.0.1") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tiles:tiles-extras:3.0.1") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
exclude group: "org.springframework", module: "spring-web"
|
||||
}
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.view.tiles3;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -21,14 +22,15 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.tiles.request.ApplicationResource;
|
||||
import org.apache.tiles.request.locale.URLApplicationResource;
|
||||
import org.apache.tiles.request.servlet.ServletApplicationContext;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.support.ServletContextResourcePatternResolver;
|
||||
|
||||
/**
|
||||
|
|
@ -39,21 +41,15 @@ import org.springframework.web.context.support.ServletContextResourcePatternReso
|
|||
*/
|
||||
public class SpringWildcardServletTilesApplicationContext extends ServletApplicationContext {
|
||||
|
||||
/**
|
||||
* The pattern resolver.
|
||||
*/
|
||||
protected ResourcePatternResolver resolver;
|
||||
private final ResourcePatternResolver resolver;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param servletContext The servlet context.
|
||||
*/
|
||||
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext) {
|
||||
super(servletContext);
|
||||
resolver = new ServletContextResourcePatternResolver(servletContext);
|
||||
this.resolver = new ServletContextResourcePatternResolver(servletContext);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ApplicationResource getResource(String localePath) {
|
||||
ApplicationResource retValue = null;
|
||||
|
|
@ -78,20 +74,22 @@ public class SpringWildcardServletTilesApplicationContext extends ServletApplica
|
|||
public Collection<ApplicationResource> getResources(String path) {
|
||||
Resource[] resources;
|
||||
try {
|
||||
resources = resolver.getResources(path);
|
||||
} catch (IOException e) {
|
||||
resources = this.resolver.getResources(path);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return Collections.<ApplicationResource> emptyList();
|
||||
}
|
||||
Collection<ApplicationResource> resourceList = new ArrayList<ApplicationResource>();
|
||||
if (resources != null && resources.length > 0) {
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
if (!ObjectUtils.isEmpty(resources)) {
|
||||
for (Resource resource : resources) {
|
||||
URL url;
|
||||
try {
|
||||
url = resources[i].getURL();
|
||||
url = resource.getURL();
|
||||
resourceList.add(new URLApplicationResource(url.toExternalForm(), url));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// shouldn't happen with the kind of resources we're using
|
||||
throw new IllegalArgumentException("no URL for " + resources[i].toString(), e);
|
||||
throw new IllegalArgumentException("No URL for " + resource.toString(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.springframework.web.servlet.view.tiles3;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ArrayELResolver;
|
||||
import javax.el.BeanELResolver;
|
||||
import javax.el.CompositeELResolver;
|
||||
|
|
@ -54,9 +53,11 @@ import org.apache.tiles.impl.mgmt.CachingTilesContainer;
|
|||
import org.apache.tiles.locale.LocaleResolver;
|
||||
import org.apache.tiles.preparer.factory.PreparerFactory;
|
||||
import org.apache.tiles.request.ApplicationContext;
|
||||
import org.apache.tiles.request.ApplicationContextAware;
|
||||
import org.apache.tiles.request.ApplicationResource;
|
||||
import org.apache.tiles.startup.DefaultTilesInitializer;
|
||||
import org.apache.tiles.startup.TilesInitializer;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.PropertyAccessorFactory;
|
||||
|
|
@ -83,7 +84,7 @@ import org.springframework.web.context.ServletContextAware;
|
|||
*
|
||||
* <p>A typical TilesConfigurer bean definition looks as follows:
|
||||
*
|
||||
* <pre>
|
||||
* <pre class="code">
|
||||
* <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
|
||||
* <property name="definitions">
|
||||
* <list>
|
||||
|
|
@ -103,6 +104,8 @@ import org.springframework.web.context.ServletContextAware;
|
|||
* @author mick semb wever
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
* @see TilesView
|
||||
* @see TilesViewResolver
|
||||
*/
|
||||
public class TilesConfigurer implements ServletContextAware, InitializingBean, DisposableBean {
|
||||
|
||||
|
|
@ -128,8 +131,6 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
|
||||
private ServletContext servletContext;
|
||||
|
||||
public TilesConfigurer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Tiles using a custom TilesInitializer, typically specified as an inner bean.
|
||||
|
|
@ -158,10 +159,11 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
try {
|
||||
this.tilesInitializer = new SpringCompleteAutoloadTilesInitializer();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("tiles-extras 3.x not available", ex);
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Tiles-Extras 3.0 not available", ex);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.tilesInitializer = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -170,7 +172,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
* Set the Tiles definitions, i.e. the list of files containing the definitions.
|
||||
* Default is "/WEB-INF/tiles.xml".
|
||||
*/
|
||||
public void setDefinitions(String[] definitions) {
|
||||
public void setDefinitions(String... definitions) {
|
||||
this.definitions = definitions;
|
||||
}
|
||||
|
||||
|
|
@ -315,8 +317,8 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
|
||||
if (definitionsFactoryClass != null) {
|
||||
DefinitionsFactory factory = BeanUtils.instantiate(definitionsFactoryClass);
|
||||
if (factory instanceof org.apache.tiles.request.ApplicationContextAware) {
|
||||
((org.apache.tiles.request.ApplicationContextAware) factory).setApplicationContext(applicationContext);
|
||||
if (factory instanceof ApplicationContextAware) {
|
||||
((ApplicationContextAware) factory).setApplicationContext(applicationContext);
|
||||
}
|
||||
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory);
|
||||
if (bw.isWritableProperty("localeResolver")) {
|
||||
|
|
@ -363,6 +365,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private class SpringCompleteAutoloadTilesInitializer extends CompleteAutoloadTilesInitializer {
|
||||
|
||||
@Override
|
||||
|
|
@ -371,6 +374,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private class SpringCompleteAutoloadTilesContainerFactory extends CompleteAutoloadTilesContainerFactory {
|
||||
|
||||
@Override
|
||||
|
|
@ -407,6 +411,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CompositeELResolverImpl extends CompositeELResolver {
|
||||
|
||||
public CompositeELResolverImpl() {
|
||||
|
|
@ -420,4 +425,5 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
add(new BeanELResolver(false));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.web.servlet.view.tiles3;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.apache.tiles.access.TilesAccess;
|
||||
import org.apache.tiles.impl.BasicTilesContainer;
|
||||
import org.apache.tiles.request.ApplicationContext;
|
||||
|
|
@ -25,11 +23,14 @@ import org.apache.tiles.request.Request;
|
|||
import org.apache.tiles.request.servlet.ServletRequest;
|
||||
import org.apache.tiles.request.servlet.ServletUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.test.MockServletContext;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link TilesConfigurer}.
|
||||
*
|
||||
|
|
@ -42,7 +43,7 @@ public class TilesConfigurerTests {
|
|||
MockServletContext servletContext = new MockServletContext();
|
||||
|
||||
TilesConfigurer tc = new TilesConfigurer();
|
||||
tc.setDefinitions(new String[] { "/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml" });
|
||||
tc.setDefinitions("/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml");
|
||||
tc.setCheckRefresh(true);
|
||||
tc.setServletContext(servletContext);
|
||||
tc.afterPropertiesSet();
|
||||
|
|
@ -57,6 +58,7 @@ public class TilesConfigurerTests {
|
|||
tc.destroy();
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
public static class AppConfig {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
|
|
@ -200,7 +200,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
"org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer");
|
||||
this.tilesInitializer = (TilesInitializer) clazz.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Tiles-Extras 2.2 not available", ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
|||
* Set the Tiles definitions, i.e. the list of files containing the definitions.
|
||||
* Default is "/WEB-INF/tiles.xml".
|
||||
*/
|
||||
public void setDefinitions(String[] definitions) {
|
||||
public void setDefinitions(String... definitions) {
|
||||
this.definitions = definitions;
|
||||
if (definitions != null) {
|
||||
String defs = StringUtils.arrayToCommaDelimitedString(definitions);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
|
|
@ -36,7 +36,7 @@ public class TilesConfigurerTests {
|
|||
public void simpleBootstrap() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
TilesConfigurer tc = new TilesConfigurer();
|
||||
tc.setDefinitions(new String[] {"/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml"});
|
||||
tc.setDefinitions("/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml");
|
||||
tc.setCheckRefresh(true);
|
||||
tc.setServletContext(sc);
|
||||
tc.afterPropertiesSet();
|
||||
|
|
|
|||
Loading…
Reference in New Issue