diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java index 2713daeea40..75afad31e98 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -41,25 +41,26 @@ public abstract class AbstractResourceResolver implements ResourceResolver { List locations, ResourceResolverChain chain) { if (logger.isTraceEnabled()) { - logger.trace("Resolving resource: requestPath=\"" + requestPath + "\""); + logger.trace("Resolving resource for request path \"" + requestPath + "\""); } return resolveResourceInternal(request, requestPath, locations, chain); } - protected abstract Resource resolveResourceInternal(HttpServletRequest request, String requestPath, - List locations, ResourceResolverChain chain); - @Override public String resolveUrlPath(String resourceUrlPath, List locations, ResourceResolverChain chain) { if (logger.isTraceEnabled()) { - logger.trace("Resolving public URL for path=\"" + resourceUrlPath + "\""); + logger.trace("Resolving public URL for resource path \"" + resourceUrlPath + "\""); } return resolveUrlPathInternal(resourceUrlPath, locations, chain); } + + protected abstract Resource resolveResourceInternal(HttpServletRequest request, String requestPath, + List locations, ResourceResolverChain chain); + protected abstract String resolveUrlPathInternal(String resourceUrlPath, List locations, ResourceResolverChain chain); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index b4628118bf0..ba4922c27c1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringWriter; import java.nio.charset.Charset; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Scanner; @@ -97,9 +97,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { throws IOException { resource = transformerChain.transform(request, resource); - - String filename = resource.getFilename(); - if (!this.fileExtension.equals(StringUtils.getFilenameExtension(filename))) { + if (!this.fileExtension.equals(StringUtils.getFilenameExtension(resource.getFilename()))) { return resource; } @@ -138,7 +136,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { String hash = hashBuilder.build(); contentWriter.write("\n" + "# Hash: " + hash); if (logger.isTraceEnabled()) { - logger.trace("AppCache file: [" + resource.getFilename()+ "] Hash: [" + hash + "]"); + logger.trace("AppCache file: [" + resource.getFilename()+ "] hash: [" + hash + "]"); } return new TransformedResource(resource, contentWriter.toString().getBytes(DEFAULT_CHARSET)); @@ -170,7 +168,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { private class CacheSection implements SectionTransformer { - private final String COMMENT_DIRECTIVE = "#"; + private static final String COMMENT_DIRECTIVE = "#"; @Override public String transform(String line, HashBuilder builder, Resource resource, @@ -178,7 +176,8 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { if (isLink(line) && !hasScheme(line)) { ResourceResolverChain resolverChain = transformerChain.getResolverChain(); - Resource appCacheResource = resolverChain.resolveResource(null, line, Arrays.asList(resource)); + Resource appCacheResource = + resolverChain.resolveResource(null, line, Collections.singletonList(resource)); String path = resolveUrlPath(line, request, resource, transformerChain); builder.appendResource(appCacheResource); if (logger.isTraceEnabled()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java index 669e5a2fdfa..7cbe522b559 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java @@ -42,15 +42,17 @@ public class CachingResourceResolver extends AbstractResourceResolver { private final Cache cache; + public CachingResourceResolver(CacheManager cacheManager, String cacheName) { this(cacheManager.getCache(cacheName)); } public CachingResourceResolver(Cache cache) { - Assert.notNull(cache, "'cache' is required"); + Assert.notNull(cache, "Cache is required"); this.cache = cache; } + /** * Return the configured {@code Cache}. */ @@ -58,6 +60,7 @@ public class CachingResourceResolver extends AbstractResourceResolver { return this.cache; } + @Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List locations, ResourceResolverChain chain) { @@ -67,7 +70,7 @@ public class CachingResourceResolver extends AbstractResourceResolver { if (resource != null) { if (logger.isTraceEnabled()) { - logger.trace("Found match"); + logger.trace("Found match: " + resource); } return resource; } @@ -75,7 +78,7 @@ public class CachingResourceResolver extends AbstractResourceResolver { resource = chain.resolveResource(request, requestPath, locations); if (resource != null) { if (logger.isTraceEnabled()) { - logger.trace("Putting resolved resource in cache"); + logger.trace("Putting resolved resource in cache: " + resource); } this.cache.put(key, resource); } @@ -104,7 +107,7 @@ public class CachingResourceResolver extends AbstractResourceResolver { if (resolvedUrlPath != null) { if (logger.isTraceEnabled()) { - logger.trace("Found match"); + logger.trace("Found match: \"" + resolvedUrlPath + "\""); } return resolvedUrlPath; } @@ -112,7 +115,7 @@ public class CachingResourceResolver extends AbstractResourceResolver { resolvedUrlPath = chain.resolveUrlPath(resourceUrlPath, locations); if (resolvedUrlPath != null) { if (logger.isTraceEnabled()) { - logger.trace("Putting resolved resource URL path in cache"); + logger.trace("Putting resolved resource URL path in cache: \"" + resolvedUrlPath + "\""); } this.cache.put(key, resolvedUrlPath); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java index 675c6ff676e..aac32a80ed9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java @@ -42,12 +42,13 @@ public class CachingResourceTransformer implements ResourceTransformer { private final Cache cache; + public CachingResourceTransformer(CacheManager cacheManager, String cacheName) { this(cacheManager.getCache(cacheName)); } public CachingResourceTransformer(Cache cache) { - Assert.notNull(cache, "'cache' is required"); + Assert.notNull(cache, "Cache is required"); this.cache = cache; } @@ -59,6 +60,7 @@ public class CachingResourceTransformer implements ResourceTransformer { return this.cache; } + @Override public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException { @@ -66,7 +68,7 @@ public class CachingResourceTransformer implements ResourceTransformer { Resource transformed = this.cache.get(resource, Resource.class); if (transformed != null) { if (logger.isTraceEnabled()) { - logger.trace("Found match"); + logger.trace("Found match: " + transformed); } return transformed; } @@ -74,7 +76,7 @@ public class CachingResourceTransformer implements ResourceTransformer { transformed = transformerChain.transform(request, resource); if (logger.isTraceEnabled()) { - logger.trace("Putting transformed resource in cache"); + logger.trace("Putting transformed resource in cache: " + transformed); } this.cache.put(resource, transformed); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java index c9a3c9175a3..7c722781770 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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.resource; import java.io.IOException; @@ -33,12 +34,10 @@ import org.springframework.util.FileCopyUtils; */ public class ContentVersionStrategy extends AbstractVersionStrategy { - public ContentVersionStrategy() { super(new FileNameVersionPathStrategy()); } - @Override public String getResourceVersion(Resource resource) { try { @@ -46,7 +45,7 @@ public class ContentVersionStrategy extends AbstractVersionStrategy { return DigestUtils.md5DigestAsHex(content); } catch (IOException ex) { - throw new IllegalStateException("Failed to calculate hash for resource [" + resource + "]", ex); + throw new IllegalStateException("Failed to calculate hash for " + resource, ex); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java index 52445e7b389..7bb638f206d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.core.io.Resource; import org.springframework.util.Assert; - /** * A default implementation of {@link ResourceResolverChain} for invoking a list * of {@link ResourceResolver}s. @@ -53,6 +52,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain { if (resolver == null) { return null; } + try { return resolver.resolveResource(request, requestPath, locations, this); } @@ -67,6 +67,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain { if (resolver == null) { return null; } + try { return resolver.resolveUrlPath(resourcePath, locations, this); } @@ -76,7 +77,6 @@ class DefaultResourceResolverChain implements ResourceResolverChain { } private ResourceResolver getNext() { - Assert.state(this.index <= this.resolvers.size(), "Current index exceeds the number of configured ResourceResolver's"); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java index c8e56cf97be..136d03009bf 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -25,8 +25,8 @@ import org.springframework.core.io.Resource; import org.springframework.util.Assert; /** - * A default implementation of {@link ResourceTransformerChain} for invoking a list - * of {@link ResourceTransformer}s. + * A default implementation of {@link ResourceTransformerChain} for invoking + * a list of {@link ResourceTransformer}s. * * @author Rossen Stoyanchev * @since 4.1 @@ -39,10 +39,11 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain { private int index = -1; + public DefaultResourceTransformerChain(ResourceResolverChain resolverChain, List transformers) { - Assert.notNull(resolverChain, "'resolverChain' is required"); + Assert.notNull(resolverChain, "ResourceResolverChain is required"); this.resolverChain = resolverChain; if (transformers != null) { this.transformers.addAll(transformers); @@ -54,12 +55,14 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain { return this.resolverChain; } + @Override public Resource transform(HttpServletRequest request, Resource resource) throws IOException { ResourceTransformer transformer = getNext(); if (transformer == null) { return resource; } + try { return transformer.transform(request, resource, this); } @@ -69,7 +72,6 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain { } private ResourceTransformer getNext() { - Assert.state(this.index <= this.transformers.size(), "Current index exceeds the number of configured ResourceTransformer's"); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java index 180bc6e88a1..4a81a38c513 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -117,7 +117,7 @@ public class DefaultServletHttpRequestHandler implements HttpRequestHandler, Ser RequestDispatcher rd = this.servletContext.getNamedDispatcher(this.defaultServletName); if (rd == null) { throw new IllegalStateException("A RequestDispatcher could not be located for the default servlet '" + - this.defaultServletName +"'"); + this.defaultServletName + "'"); } rd.forward(request, response); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java index d3ceb17829d..e3b44e25731 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -18,7 +18,6 @@ package org.springframework.web.servlet.resource; import org.springframework.core.io.Resource; - /** * Interface for a resource descriptor that describes the encoding * applied to the entire resource content. @@ -39,6 +38,6 @@ public interface EncodedResource extends Resource { * @see HTTP/1.1: Semantics * and Content, section 3.1.2.1 */ - public String getContentEncoding(); + String getContentEncoding(); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java index eacc0052024..d46b2dd0287 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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.resource; import org.springframework.core.io.Resource; @@ -34,6 +35,7 @@ public class FixedVersionStrategy extends AbstractVersionStrategy { private final String version; + /** * Create a new FixedVersionStrategy with the given version string. * @param version the fixed version string to use diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java index dadde77f4c6..4c457db2a89 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java @@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.core.io.AbstractResource; import org.springframework.core.io.Resource; - /** * A {@code ResourceResolver} that delegates to the chain to locate a resource * and then attempts to find a variation with the ".gz" extension. @@ -42,7 +41,6 @@ import org.springframework.core.io.Resource; */ public class GzipResourceResolver extends AbstractResourceResolver { - @Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List locations, ResourceResolverChain chain) { @@ -58,8 +56,8 @@ public class GzipResourceResolver extends AbstractResourceResolver { return gzipped; } } - catch (IOException e) { - logger.trace("No gzipped resource for [" + resource.getFilename() + "]", e); + catch (IOException ex) { + logger.trace("No gzipped resource for [" + resource.getFilename() + "]", ex); } return resource; @@ -67,7 +65,7 @@ public class GzipResourceResolver extends AbstractResourceResolver { private boolean isGzipAccepted(HttpServletRequest request) { String value = request.getHeader("Accept-Encoding"); - return ((value != null) && value.toLowerCase().contains("gzip")); + return (value != null && value.toLowerCase().contains("gzip")); } @Override @@ -84,13 +82,11 @@ public class GzipResourceResolver extends AbstractResourceResolver { private final Resource gzipped; - public GzippedResource(Resource original) throws IOException { this.original = original; this.gzipped = original.createRelative(original.getFilename() + ".gz"); } - public InputStream getInputStream() throws IOException { return this.gzipped.getInputStream(); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java index 3d5241b3e30..d9a974129de 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -25,8 +25,8 @@ import org.springframework.core.io.Resource; * A strategy for resolving a request to a server-side resource. * *

Provides mechanisms for resolving an incoming request to an actual - * {@link org.springframework.core.io.Resource} and for obtaining the public - * URL path that clients should use when requesting the resource. + * {@link org.springframework.core.io.Resource} and for obtaining the + * public URL path that clients should use when requesting the resource. * * @author Jeremy Grelle * @author Rossen Stoyanchev @@ -39,7 +39,6 @@ public interface ResourceResolver { /** * Resolve the supplied request and request path to a {@link Resource} that * exists under one of the given resource locations. - * * @param request the current request * @param requestPath the portion of the request path to use * @param locations the locations to search in when looking up resources @@ -53,9 +52,7 @@ public interface ResourceResolver { * Resolve the externally facing public URL path for clients to use * to access the resource that is located at the given internal * resource path. - * *

This is useful when rendering URL links to clients. - * * @param resourcePath the internal resource path * @param locations the locations to search in when looking up resources * @param chain the chain of resolvers to delegate to diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java index a260f26216c..65a03a2436b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -35,7 +35,6 @@ public interface ResourceResolverChain { /** * Resolve the supplied request and request path to a {@link Resource} that * exists under one of the given resource locations. - * * @param request the current request * @param requestPath the portion of the request path to use * @param locations the locations to search in when looking up resources @@ -47,9 +46,7 @@ public interface ResourceResolverChain { * Resolve the externally facing public URL path for clients to use * to access the resource that is located at the given internal * resource path. - * *

This is useful when rendering URL links to clients. - * * @param resourcePath the internal resource path * @param locations the locations to search in when looking up resources * @return the resolved public URL path or {@code null} if unresolved diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java index a477ec51baa..fe941d830bf 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.servlet.resource; +package org.springframework.web.servlet.resource; import java.io.IOException; import javax.servlet.http.HttpServletRequest; @@ -32,12 +32,10 @@ public interface ResourceTransformer { /** * Transform the given resource. - * * @param request the current request * @param resource the resource to transform * @param transformerChain the chain of remaining transformers to delegate to * @return the transformed resource, never {@code null} - * * @throws IOException if the transformation fails */ Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java index 69a22b74edf..bc506751bc6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -39,12 +39,10 @@ public interface ResourceTransformerChain { /** * Transform the given resource. - * * @param request the current request * @param resource the candidate resource to transform * @return the transformed or the same resource, never {@code null} - * - * @throws java.io.IOException if transformation fails + * @throws IOException if transformation fails */ Resource transform(HttpServletRequest request, Resource resource) throws IOException; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java index 4cdb2deff25..c3f0b5e2d6f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.resource; -import java.util.Arrays; +import java.util.Collections; import javax.servlet.http.HttpServletRequest; import org.springframework.core.io.Resource; @@ -38,7 +39,6 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer * URL of links in a transformed resource (e.g. import links in a CSS file). * This is required only for links expressed as full paths, i.e. including * context and servlet path, and not for relative links. - * *

By default this property is not set. In that case if a * {@code ResourceUrlProvider} is needed an attempt is made to find the * {@code ResourceUrlProvider} exposed through the @@ -65,7 +65,6 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer * contains links to other resources. Such links need to be replaced with the * public facing link as determined by the resource resolver chain (e.g. the * public URL may have a version inserted). - * * @param resourcePath the path to a resource that needs to be re-written * @param request the current request * @param resource the resource being transformed @@ -82,7 +81,8 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer } else { // try resolving as relative path - return transformerChain.getResolverChain().resolveUrlPath(resourcePath, Arrays.asList(resource)); + return transformerChain.getResolverChain().resolveUrlPath( + resourcePath, Collections.singletonList(resource)); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java index c094c671359..414220ee59f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -22,9 +22,9 @@ import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; /** - * An extension of {@link org.springframework.core.io.ByteArrayResource} that a - * {@link ResourceTransformer} can use to represent an original resource - * preserving all other information except the content. + * An extension of {@link org.springframework.core.io.ByteArrayResource} + * that a {@link ResourceTransformer} can use to represent an original + * resource preserving all other information except the content. * * @author Jeremy Grelle * @author Rossen Stoyanchev @@ -43,9 +43,9 @@ public class TransformedResource extends ByteArrayResource { try { this.lastModified = original.lastModified(); } - catch (IOException e) { + catch (IOException ex) { // should never happen - throw new IllegalArgumentException(e); + throw new IllegalArgumentException(ex); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java index 995145ed53b..765a5810f2e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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.resource; /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java index 1893566f9a3..b14ec54dca0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.resource; import org.springframework.core.io.Resource; /** - * An extension of {@link VersionPathStrategy} that adds a method to determine the - * actual version of a {@link org.springframework.core.io.Resource Resource}. + * An extension of {@link VersionPathStrategy} that adds a method + * to determine the actual version of a {@link Resource}. * * @author Brian Clozel * @author Rossen Stoyanchev @@ -29,9 +30,9 @@ import org.springframework.core.io.Resource; public interface VersionStrategy extends VersionPathStrategy { /** - * Get the version for the given resource. + * Determine the version for the given resource. * @param resource the resource to check - * @return the version, never {@code null} + * @return the version (never {@code null}) */ String getResourceVersion(Resource resource);