Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -46,24 +46,23 @@ public class AnnotationBeanWiringInfoResolver implements BeanWiringInfoResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the BeanWiringInfo for the given Configurable annotation.
|
* Build the {@link BeanWiringInfo} for the given {@link Configurable} annotation.
|
||||||
* @param beanInstance the bean instance
|
* @param beanInstance the bean instance
|
||||||
* @param annotation the Configurable annotation found on the bean class
|
* @param annotation the Configurable annotation found on the bean class
|
||||||
* @return the resolved BeanWiringInfo
|
* @return the resolved BeanWiringInfo
|
||||||
*/
|
*/
|
||||||
protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annotation) {
|
protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annotation) {
|
||||||
if (!Autowire.NO.equals(annotation.autowire())) {
|
if (!Autowire.NO.equals(annotation.autowire())) {
|
||||||
|
// Autowiring by name or by type
|
||||||
return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck());
|
return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck());
|
||||||
}
|
}
|
||||||
|
else if (!"".equals(annotation.value())) {
|
||||||
|
// Explicitly specified bean name for bean definition to take property values from
|
||||||
|
return new BeanWiringInfo(annotation.value(), false);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (!"".equals(annotation.value())) {
|
// Default bean name for bean definition to take property values from
|
||||||
// explicitly specified bean name
|
return new BeanWiringInfo(getDefaultBeanName(beanInstance), true);
|
||||||
return new BeanWiringInfo(annotation.value(), false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// default bean name
|
|
||||||
return new BeanWiringInfo(getDefaultBeanName(beanInstance), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -96,7 +96,7 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
|
|||||||
*/
|
*/
|
||||||
protected String toAbsolutePath(String path, ServerWebExchange exchange) {
|
protected String toAbsolutePath(String path, ServerWebExchange exchange) {
|
||||||
String requestPath = exchange.getRequest().getURI().getPath();
|
String requestPath = exchange.getRequest().getURI().getPath();
|
||||||
String absolutePath = path.startsWith("/") ? path : StringUtils.applyRelativePath(requestPath, path);
|
String absolutePath = (path.startsWith("/") ? path : StringUtils.applyRelativePath(requestPath, path));
|
||||||
return StringUtils.cleanPath(absolutePath);
|
return StringUtils.cleanPath(absolutePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -37,7 +37,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
|||||||
import org.springframework.web.util.pattern.PathPatternParser;
|
import org.springframework.web.util.pattern.PathPatternParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the following request mapping conditions:
|
* Request mapping information. Encapsulates the following request mapping conditions:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>{@link PatternsRequestCondition}
|
* <li>{@link PatternsRequestCondition}
|
||||||
* <li>{@link RequestMethodsRequestCondition}
|
* <li>{@link RequestMethodsRequestCondition}
|
||||||
@@ -201,7 +201,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (other.name != null ? other.name : null);
|
return other.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
|||||||
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
||||||
|
|
||||||
return new RequestMappingInfo(this.mappingName, patternsCondition,
|
return new RequestMappingInfo(this.mappingName, patternsCondition,
|
||||||
new RequestMethodsRequestCondition(methods),
|
new RequestMethodsRequestCondition(this.methods),
|
||||||
new ParamsRequestCondition(this.params),
|
new ParamsRequestCondition(this.params),
|
||||||
new HeadersRequestCondition(this.headers),
|
new HeadersRequestCondition(this.headers),
|
||||||
new ConsumesRequestCondition(this.consumes, this.headers),
|
new ConsumesRequestCondition(this.consumes, this.headers),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -95,7 +95,7 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
|
|||||||
*/
|
*/
|
||||||
protected String toAbsolutePath(String path, HttpServletRequest request) {
|
protected String toAbsolutePath(String path, HttpServletRequest request) {
|
||||||
String absolutePath = path;
|
String absolutePath = path;
|
||||||
if(!path.startsWith("/")) {
|
if (!path.startsWith("/")) {
|
||||||
ResourceUrlProvider urlProvider = findResourceUrlProvider(request);
|
ResourceUrlProvider urlProvider = findResourceUrlProvider(request);
|
||||||
Assert.state(urlProvider != null, "No ResourceUrlProvider");
|
Assert.state(urlProvider != null, "No ResourceUrlProvider");
|
||||||
String requestPath = urlProvider.getUrlPathHelper().getRequestUri(request);
|
String requestPath = urlProvider.getUrlPathHelper().getRequestUri(request);
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ import org.springframework.web.util.UrlPathHelper;
|
|||||||
/**
|
/**
|
||||||
* A filter that wraps the {@link HttpServletResponse} and overrides its
|
* A filter that wraps the {@link HttpServletResponse} and overrides its
|
||||||
* {@link HttpServletResponse#encodeURL(String) encodeURL} method in order to
|
* {@link HttpServletResponse#encodeURL(String) encodeURL} method in order to
|
||||||
* translate internal resource request URLs into public URL paths for external
|
* translate internal resource request URLs into public URL paths for external use.
|
||||||
* use.
|
|
||||||
*
|
*
|
||||||
* @author Jeremy Grelle
|
* @author Jeremy Grelle
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
@@ -52,7 +51,8 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
||||||
throws IOException, ServletException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
|
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
|
||||||
throw new ServletException("ResourceUrlEncodingFilter only supports HTTP requests");
|
throw new ServletException("ResourceUrlEncodingFilter only supports HTTP requests");
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
|||||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ResourceUrlEncodingRequestWrapper extends HttpServletRequestWrapper {
|
private static class ResourceUrlEncodingRequestWrapper extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -78,11 +79,11 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttribute(String name, Object o) {
|
public void setAttribute(String name, Object value) {
|
||||||
super.setAttribute(name, o);
|
super.setAttribute(name, value);
|
||||||
if (ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR.equals(name)) {
|
if (ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR.equals(name)) {
|
||||||
if(o instanceof ResourceUrlProvider) {
|
if (value instanceof ResourceUrlProvider) {
|
||||||
initLookupPath((ResourceUrlProvider) o);
|
initLookupPath((ResourceUrlProvider) value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,10 +110,11 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public String resolveUrlPath(String url) {
|
public String resolveUrlPath(String url) {
|
||||||
if (this.resourceUrlProvider == null) {
|
if (this.resourceUrlProvider == null) {
|
||||||
logger.debug("Request attribute exposing ResourceUrlProvider not found");
|
logger.trace("ResourceUrlProvider not available via request attribute " +
|
||||||
|
"ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (url.startsWith(this.prefixLookupPath)) {
|
if (this.indexLookupPath != null && url.startsWith(this.prefixLookupPath)) {
|
||||||
int suffixIndex = getQueryParamsIndex(url);
|
int suffixIndex = getQueryParamsIndex(url);
|
||||||
String suffix = url.substring(suffixIndex);
|
String suffix = url.substring(suffixIndex);
|
||||||
String lookupPath = url.substring(this.indexLookupPath, suffixIndex);
|
String lookupPath = url.substring(this.indexLookupPath, suffixIndex);
|
||||||
@@ -150,4 +152,4 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user