Polishing (backported from master)
This commit is contained in:
@@ -93,7 +93,7 @@ public interface HandlerInterceptor {
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception;
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Intercept the execution of a handler. Called after HandlerAdapter actually
|
||||
@@ -114,7 +114,8 @@ public interface HandlerInterceptor {
|
||||
* (can also be {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
void postHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -136,7 +137,8 @@ public interface HandlerInterceptor {
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
void afterCompletion(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -51,8 +51,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public interface LocaleResolver {
|
||||
|
||||
/**
|
||||
* Resolve the current locale via the given request. Can return a default locale as
|
||||
* fallback in any case.
|
||||
* Resolve the current locale via the given request.
|
||||
* Can return a default locale as fallback in any case.
|
||||
* @param request the request to resolve the locale for
|
||||
* @return the current locale (never {@code null})
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ public interface LocaleResolver {
|
||||
* @param request the request to be used for locale modification
|
||||
* @param response the response to be used for locale modification
|
||||
* @param locale the new locale, or {@code null} to clear the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver implementation does not
|
||||
* support dynamic changing of the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver
|
||||
* implementation does not support dynamic changing of the locale
|
||||
*/
|
||||
void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -28,9 +28,9 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* <p>This is the default implementation used by the
|
||||
* {@link org.springframework.web.servlet.DispatcherServlet}, along with
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}
|
||||
* (on Java 5 and higher). Alternatively, {@link SimpleUrlHandlerMapping} allows for
|
||||
* customizing a handler mapping declaratively.
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}.
|
||||
* Alternatively, {@link SimpleUrlHandlerMapping} allows for customizing a
|
||||
* handler mapping declaratively.
|
||||
*
|
||||
* <p>The mapping is from URL to bean name. Thus an incoming URL "/foo" would map
|
||||
* to a handler named "/foo", or to "/foo /foo2" in case of multiple mappings to
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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,7 @@ import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Abstract adapter class for the HandlerInterceptor interface,
|
||||
* Abstract adapter class for the {@link AsyncHandlerInterceptor} interface,
|
||||
* for simplified implementation of pre-only/post-only interceptors.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -36,7 +36,8 @@ public abstract class HandlerInterceptorAdapter implements AsyncHandlerIntercept
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -34,7 +34,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports
|
||||
* CompletionStage return values via an adapter mechanism.
|
||||
*/
|
||||
|
||||
@@ -114,6 +114,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapter for {@code ListenableFuture} return values.
|
||||
*/
|
||||
@@ -137,6 +138,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapter for {@code CompletionStage} return values.
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*
|
||||
* @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports
|
||||
* ListenableFuture return values via an adapter mechanism.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -49,12 +49,11 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class);
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class);
|
||||
|
||||
private final List<CssLinkParser> linkParsers = new ArrayList<CssLinkParser>();
|
||||
private final List<CssLinkParser> linkParsers = new ArrayList<CssLinkParser>(2);
|
||||
|
||||
|
||||
public CssLinkResourceTransformer() {
|
||||
@@ -81,7 +80,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
|
||||
String content = new String(bytes, DEFAULT_CHARSET);
|
||||
|
||||
Set<CssLinkInfo> infos = new HashSet<CssLinkInfo>(5);
|
||||
Set<CssLinkInfo> infos = new HashSet<CssLinkInfo>(8);
|
||||
for (CssLinkParser parser : this.linkParsers) {
|
||||
parser.parseLink(content, infos);
|
||||
}
|
||||
@@ -123,17 +122,16 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"))
|
||||
|| link.indexOf("//") == 0;
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0;
|
||||
}
|
||||
|
||||
|
||||
protected static interface CssLinkParser {
|
||||
protected interface CssLinkParser {
|
||||
|
||||
void parseLink(String content, Set<CssLinkInfo> linkInfos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static abstract class AbstractCssLinkParser implements CssLinkParser {
|
||||
|
||||
/**
|
||||
@@ -189,6 +187,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class ImportStatementCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
@@ -208,6 +207,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class UrlFunctionCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
@@ -229,8 +229,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
private final int end;
|
||||
|
||||
|
||||
private CssLinkInfo(int start, int end) {
|
||||
public CssLinkInfo(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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,10 +35,10 @@ public interface ResourceTransformer {
|
||||
* @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}
|
||||
* @return the transformed resource (never {@code null})
|
||||
* @throws IOException if the transformation fails
|
||||
*/
|
||||
Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -54,6 +54,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
|
||||
private DispatcherServlet servlet;
|
||||
|
||||
|
||||
@Test
|
||||
public void simple() throws Exception {
|
||||
initServlet(SimpleUriTemplateController.class);
|
||||
@@ -318,8 +319,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("test-42", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6640
|
||||
@Test
|
||||
@Test // SPR-6640
|
||||
public void menuTree() throws Exception {
|
||||
initServlet(MenuTreeController.class);
|
||||
|
||||
@@ -329,8 +329,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("M5", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6876
|
||||
@Test
|
||||
@Test // SPR-6876
|
||||
public void variableNames() throws Exception {
|
||||
initServlet(VariableNamesController.class);
|
||||
|
||||
@@ -345,8 +344,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("bar-bar", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-8543
|
||||
@Test
|
||||
@Test // SPR-8543
|
||||
public void variableNamesWithUrlExtension() throws Exception {
|
||||
initServlet(VariableNamesController.class);
|
||||
|
||||
@@ -356,8 +354,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("foo-foo", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-9333
|
||||
@Test
|
||||
@Test // SPR-9333
|
||||
@SuppressWarnings("serial")
|
||||
public void suppressDefaultSuffixPattern() throws Exception {
|
||||
servlet = new DispatcherServlet() {
|
||||
@@ -381,8 +378,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("foo-jsmith@mail.com", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6906
|
||||
@Test
|
||||
@Test // SPR-6906
|
||||
@SuppressWarnings("serial")
|
||||
public void controllerClassName() throws Exception {
|
||||
servlet = new DispatcherServlet() {
|
||||
@@ -416,8 +412,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
assertEquals("plain-bar", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-6978
|
||||
@Test
|
||||
@Test // SPR-6978
|
||||
public void doIt() throws Exception {
|
||||
initServlet(Spr6978Controller.class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user