Skip to content

Commit e24b876

Browse files
committed
Remove "Public" from the ResourceUrlProvider name
Also respect HandlerMapping order in ResourceUrlProvider
1 parent 70fd332 commit e24b876

17 files changed

+56
-55
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
7878
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
7979
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
80-
import org.springframework.web.servlet.resource.PublicResourceUrlProvider;
81-
import org.springframework.web.servlet.resource.PublicResourceUrlProviderExposingInterceptor;
80+
import org.springframework.web.servlet.resource.ResourceUrlProvider;
81+
import org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor;
8282
import org.springframework.web.util.UrlPathHelper;
8383

8484
/**
@@ -244,7 +244,7 @@ protected final Object[] getInterceptors() {
244244
InterceptorRegistry registry = new InterceptorRegistry();
245245
addInterceptors(registry);
246246
registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService()));
247-
registry.addInterceptor(new PublicResourceUrlProviderExposingInterceptor(resourceUrlPathTranslator()));
247+
registry.addInterceptor(new ResourceUrlProviderExposingInterceptor(resourceUrlPathTranslator()));
248248
this.interceptors = registry.getInterceptors();
249249
}
250250
return this.interceptors.toArray();
@@ -358,8 +358,8 @@ protected void addResourceHandlers(ResourceHandlerRegistry registry) {
358358
}
359359

360360
@Bean
361-
public PublicResourceUrlProvider resourceUrlPathTranslator() {
362-
PublicResourceUrlProvider translator = new PublicResourceUrlProvider();
361+
public ResourceUrlProvider resourceUrlPathTranslator() {
362+
ResourceUrlProvider translator = new ResourceUrlProvider();
363363
UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper();
364364
if (pathHelper != null) {
365365
translator.setUrlPathHelper(pathHelper);

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ protected abstract Resource resolveResourceInternal(HttpServletRequest request,
4949
List<? extends Resource> locations, ResourceResolverChain chain);
5050

5151
@Override
52-
public String resolvePublicUrlPath(String resourceUrlPath, List<? extends Resource> locations,
52+
public String resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations,
5353
ResourceResolverChain chain) {
5454

5555
if (logger.isTraceEnabled()) {
5656
logger.trace("Resolving public URL for path=\"" + resourceUrlPath + "\"");
5757
}
5858

59-
return resolvePublicUrlPathInternal(resourceUrlPath, locations, chain);
59+
return resolveUrlPathInternal(resourceUrlPath, locations, chain);
6060
}
6161

62-
protected abstract String resolvePublicUrlPathInternal(String resourceUrlPath,
62+
protected abstract String resolveUrlPathInternal(String resourceUrlPath,
6363
List<? extends Resource> locations, ResourceResolverChain chain);
6464

6565
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import javax.servlet.http.HttpServletRequest;
2323

24-
import org.apache.commons.logging.Log;
25-
import org.apache.commons.logging.LogFactory;
2624
import org.springframework.core.io.Resource;
2725
import org.springframework.util.Assert;
2826

@@ -65,13 +63,13 @@ public Resource resolveResource(HttpServletRequest request, String requestPath,
6563
}
6664

6765
@Override
68-
public String resolvePublicUrlPath(String resourcePath, List<? extends Resource> locations) {
66+
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
6967
ResourceResolver resolver = getNextResolver();
7068
if (resolver == null) {
7169
return null;
7270
}
7371
try {
74-
return resolver.resolvePublicUrlPath(resourcePath, locations, this);
72+
return resolver.resolveUrlPath(resourcePath, locations, this);
7573
}
7674
finally {
7775
this.index--;

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FingerprintResourceResolver.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import javax.servlet.http.HttpServletRequest;
2525

26-
import org.apache.commons.logging.Log;
27-
import org.apache.commons.logging.LogFactory;
2826
import org.springframework.core.io.Resource;
2927
import org.springframework.util.DigestUtils;
3028
import org.springframework.util.FileCopyUtils;
@@ -97,10 +95,10 @@ protected Resource resolveResourceInternal(HttpServletRequest request, String re
9795
}
9896

9997
@Override
100-
protected String resolvePublicUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
98+
protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
10199
ResourceResolverChain chain) {
102100

103-
String baseUrl = chain.resolvePublicUrlPath(resourceUrlPath, locations);
101+
String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations);
104102
if (StringUtils.hasText(baseUrl)) {
105103
if (logger.isTraceEnabled()) {
106104
logger.trace("Getting the original resource to calculate hash");

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
import javax.servlet.http.HttpServletRequest;
2727

28-
import org.apache.commons.logging.Log;
29-
import org.apache.commons.logging.LogFactory;
3028
import org.springframework.core.io.AbstractResource;
3129
import org.springframework.core.io.Resource;
3230

@@ -74,10 +72,10 @@ private boolean isGzipAccepted(HttpServletRequest request) {
7472
}
7573

7674
@Override
77-
protected String resolvePublicUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
75+
protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
7876
ResourceResolverChain chain) {
7977

80-
return chain.resolvePublicUrlPath(resourceUrlPath, locations);
78+
return chain.resolveUrlPath(resourceUrlPath, locations);
8179
}
8280

8381

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected Resource resolveResourceInternal(HttpServletRequest request, String re
4848
}
4949

5050
@Override
51-
protected String resolvePublicUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
51+
protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
5252
ResourceResolverChain chain) {
5353

5454
return (getResource(resourceUrlPath, locations) != null ? resourceUrlPath : null);

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PrefixResourceResolver.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.web.servlet.resource;
1818

19-
import org.apache.commons.logging.Log;
20-
import org.apache.commons.logging.LogFactory;
2119
import org.springframework.core.io.Resource;
2220
import org.springframework.util.Assert;
2321
import org.springframework.util.StringUtils;
@@ -63,10 +61,10 @@ protected Resource resolveResourceInternal(HttpServletRequest request, String re
6361
}
6462

6563
@Override
66-
protected String resolvePublicUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
64+
protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations,
6765
ResourceResolverChain chain) {
6866

69-
String baseUrl = chain.resolvePublicUrlPath(resourceUrlPath, locations);
67+
String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations);
7068
if (StringUtils.hasText(baseUrl)) {
7169
return this.prefix + (baseUrl.startsWith("/") ? baseUrl : "/" + baseUrl);
7270
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ Resource resolveResource(HttpServletRequest request, String requestPath, List<?
6262
* @param chain the chain of resolvers to delegate to
6363
* @return the resolved public URL path or {@code null} if unresolved
6464
*/
65-
String resolvePublicUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain);
65+
String resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain);
6666

6767
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public interface ResourceResolverChain {
5656
* @param locations the locations to search in when looking up resources
5757
* @return the resolved public URL path or {@code null} if unresolved
5858
*/
59-
String resolvePublicUrlPath(String resourcePath, List<? extends Resource> locations);
59+
String resolveUrlPath(String resourcePath, List<? extends Resource> locations);
6060

6161
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ private ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServl
6565

6666
@Override
6767
public String encodeURL(String url) {
68-
String name = PublicResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR;
69-
PublicResourceUrlProvider urlProvider = (PublicResourceUrlProvider) this.request.getAttribute(name);
68+
String name = ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR;
69+
ResourceUrlProvider urlProvider = (ResourceUrlProvider) this.request.getAttribute(name);
7070
if (urlProvider != null) {
7171
String translatedUrl = urlProvider.getForRequestUrl(this.request, url);
7272
if (translatedUrl != null) {
7373
return super.encodeURL(translatedUrl);
7474
}
7575
}
7676
else {
77-
logger.debug("Request attribute exposing PublicResourceUrlProvider not found under name: " + name);
77+
logger.debug("Request attribute exposing ResourceUrlProvider not found under name: " + name);
7878
}
7979
return super.encodeURL(url);
8080
}

0 commit comments

Comments
 (0)