Skip to content

Commit 51a557b

Browse files
committed
Polishing
(cherry picked from commit dd7ddc0)
1 parent fc37824 commit 51a557b

File tree

5 files changed

+57
-46
lines changed

5 files changed

+57
-46
lines changed

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,20 +67,22 @@ public class MethodParameter {
6767

6868

6969
/**
70-
* Create a new MethodParameter for the given method, with nesting level 1.
70+
* Create a new {@code MethodParameter} for the given method, with nesting level 1.
7171
* @param method the Method to specify a parameter for
72-
* @param parameterIndex the index of the parameter
72+
* @param parameterIndex the index of the parameter: -1 for the method
73+
* return type; 0 for the first method parameter; 1 for the second method
74+
* parameter, etc.
7375
*/
7476
public MethodParameter(Method method, int parameterIndex) {
7577
this(method, parameterIndex, 1);
7678
}
7779

7880
/**
79-
* Create a new MethodParameter for the given method.
81+
* Create a new {@code MethodParameter} for the given method.
8082
* @param method the Method to specify a parameter for
81-
* @param parameterIndex the index of the parameter
82-
* (-1 for the method return type; 0 for the first method parameter,
83-
* 1 for the second method parameter, etc)
83+
* @param parameterIndex the index of the parameter: -1 for the method
84+
* return type; 0 for the first method parameter; 1 for the second method
85+
* parameter, etc.
8486
* @param nestingLevel the nesting level of the target type
8587
* (typically 1; e.g. in case of a List of Lists, 1 would indicate the
8688
* nested List, whereas 2 would indicate the element of the nested List)
@@ -158,31 +160,31 @@ public Constructor<?> getConstructor() {
158160
}
159161

160162
/**
161-
* Returns the wrapped member.
163+
* Return the class that declares the underlying Method or Constructor.
164+
*/
165+
public Class<?> getDeclaringClass() {
166+
return getMember().getDeclaringClass();
167+
}
168+
169+
/**
170+
* Return the wrapped member.
162171
* @return the Method or Constructor as Member
163172
*/
164173
private Member getMember() {
165174
return (this.method != null ? this.method : this.constructor);
166175
}
167176

168177
/**
169-
* Returns the wrapped annotated element.
178+
* Return the wrapped annotated element.
170179
* @return the Method or Constructor as AnnotatedElement
171180
*/
172181
private AnnotatedElement getAnnotatedElement() {
173182
return (this.method != null ? this.method : this.constructor);
174183
}
175184

176-
/**
177-
* Return the class that declares the underlying Method or Constructor.
178-
*/
179-
public Class<?> getDeclaringClass() {
180-
return getMember().getDeclaringClass();
181-
}
182-
183185
/**
184186
* Return the index of the method/constructor parameter.
185-
* @return the parameter index (never negative)
187+
* @return the parameter index (-1 in case of the return type)
186188
*/
187189
public int getParameterIndex() {
188190
return this.parameterIndex;
@@ -216,6 +218,7 @@ public Class<?> getParameterType() {
216218
/**
217219
* Return the generic type of the method/constructor parameter.
218220
* @return the parameter type (never {@code null})
221+
* @since 3.0
219222
*/
220223
public Type getGenericParameterType() {
221224
if (this.genericParameterType == null) {
@@ -231,6 +234,12 @@ public Type getGenericParameterType() {
231234
return this.genericParameterType;
232235
}
233236

237+
/**
238+
* Return the nested type of the method/constructor parameter.
239+
* @return the parameter type (never {@code null})
240+
* @since 3.1
241+
* @see #getNestingLevel()
242+
*/
234243
public Class<?> getNestedParameterType() {
235244
if (this.nestingLevel > 1) {
236245
Type type = getGenericParameterType();

spring-core/src/main/java/org/springframework/core/convert/ConversionService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,19 +64,19 @@ public interface ConversionService {
6464

6565
/**
6666
* Convert the given {@code source} to the specified {@code targetType}.
67-
* @param source the source object to convert (may be null)
67+
* @param source the source object to convert (may be {@code null})
6868
* @param targetType the target type to convert to (required)
6969
* @return the converted object, an instance of targetType
7070
* @throws ConversionException if a conversion exception occurred
71-
* @throws IllegalArgumentException if targetType is null
71+
* @throws IllegalArgumentException if targetType is {@code null}
7272
*/
7373
<T> T convert(Object source, Class<T> targetType);
7474

7575
/**
7676
* Convert the given {@code source} to the specified {@code targetType}.
7777
* The TypeDescriptors provide additional context about the source and target locations
7878
* where conversion will occur, often object fields or property locations.
79-
* @param source the source object to convert (may be null)
79+
* @param source the source object to convert (may be {@code null})
8080
* @param sourceType context about the source type to convert from
8181
* (may be {@code null} if source is {@code null})
8282
* @param targetType context about the target type to convert to (required)

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@
3939
*
4040
* @author Rossen Stoyanchev
4141
* @since 3.2
42-
*
4342
* @see org.springframework.web.context.request.async.WebAsyncManager
4443
* @see org.springframework.web.context.request.async.CallableProcessingInterceptor
4544
* @see org.springframework.web.context.request.async.DeferredResultProcessingInterceptor
@@ -48,19 +47,17 @@ public interface AsyncHandlerInterceptor extends HandlerInterceptor {
4847

4948
/**
5049
* Called instead of {@code postHandle} and {@code afterCompletion}, when
51-
* the a handler is being executed concurrently. Implementations may use the
52-
* provided request and response but should avoid modifying them in ways
53-
* that would conflict with the concurrent execution of the handler. A
54-
* typical use of this method would be to clean thread local variables.
55-
*
50+
* the a handler is being executed concurrently. Implementations may use
51+
* the provided request and response but should avoid modifying them in
52+
* ways that would conflict with the concurrent execution of the handler.
53+
* A typical use of this method would be to clean thread local variables.
5654
* @param request the current request
5755
* @param response the current response
5856
* @param handler handler (or {@link HandlerMethod}) that started async
5957
* execution, for type and/or instance examination
6058
* @throws Exception in case of errors
6159
*/
62-
void afterConcurrentHandlingStarted(
63-
HttpServletRequest request, HttpServletResponse response, Object handler)
60+
void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)
6461
throws Exception;
6562

6663
}

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@
3333
* or common handler behavior like locale or theme changes. Its main purpose
3434
* is to allow for factoring out repetitive handler code.
3535
*
36-
* <p>In an async processing scenario, the handler may be executed in a separate
37-
* thread while the main thread exits without rendering or invoking the
36+
* <p>In an asynchronous processing scenario, the handler may be executed in a
37+
* separate thread while the main thread exits without rendering or invoking the
3838
* {@code postHandle} and {@code afterCompletion} callbacks. When concurrent
3939
* handler execution completes, the request is dispatched back in order to
4040
* proceed with rendering the model and all methods of this contract are invoked
@@ -48,7 +48,7 @@
4848
* in the application context, referenced by the mapping bean definition
4949
* via its "interceptors" property (in XML: a &lt;list&gt; of &lt;ref&gt;).
5050
*
51-
* <p>HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in
51+
* <p>HandlerInterceptor is basically similar to a Servlet Filter, but in
5252
* contrast to the latter it just allows custom pre-processing with the option
5353
* of prohibiting the execution of the handler itself, and custom post-processing.
5454
* Filters are more powerful, for example they allow for exchanging the request
@@ -81,6 +81,9 @@ public interface HandlerInterceptor {
8181
* of any number of interceptors, with the handler itself at the end.
8282
* With this method, each interceptor can decide to abort the execution chain,
8383
* typically sending a HTTP error or writing a custom response.
84+
* <p><strong>Note:</strong> special considerations apply for asynchronous
85+
* request processing. For more details see
86+
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
8487
* @param request current HTTP request
8588
* @param response current HTTP response
8689
* @param handler chosen handler to execute, for type and/or instance evaluation
@@ -100,16 +103,18 @@ boolean preHandle(HttpServletRequest request, HttpServletResponse response, Obje
100103
* of any number of interceptors, with the handler itself at the end.
101104
* With this method, each interceptor can post-process an execution,
102105
* getting applied in inverse order of the execution chain.
106+
* <p><strong>Note:</strong> special considerations apply for asynchronous
107+
* request processing. For more details see
108+
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
103109
* @param request current HTTP request
104110
* @param response current HTTP response
105-
* @param handler handler (or {@link HandlerMethod}) that started async
111+
* @param handler handler (or {@link HandlerMethod}) that started asynchronous
106112
* execution, for type and/or instance examination
107113
* @param modelAndView the {@code ModelAndView} that the handler returned
108114
* (can also be {@code null})
109115
* @throws Exception in case of errors
110116
*/
111-
void postHandle(
112-
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
117+
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
113118
throws Exception;
114119

115120
/**
@@ -121,15 +126,17 @@ void postHandle(
121126
* <p>As with the {@code postHandle} method, the method will be invoked on each
122127
* interceptor in the chain in reverse order, so the first interceptor will be
123128
* the last to be invoked.
129+
* <p><strong>Note:</strong> special considerations apply for asynchronous
130+
* request processing. For more details see
131+
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
124132
* @param request current HTTP request
125133
* @param response current HTTP response
126-
* @param handler handler (or {@link HandlerMethod}) that started async
134+
* @param handler handler (or {@link HandlerMethod}) that started asynchronous
127135
* execution, for type and/or instance examination
128136
* @param ex exception thrown on handler execution, if any
129137
* @throws Exception in case of errors
130138
*/
131-
void afterCompletion(
132-
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
139+
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
133140
throws Exception;
134141

135142
}

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodExceptionResolver.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
3434

3535
/**
3636
* Checks if the handler is a {@link HandlerMethod} and then delegates to the
37-
* base class implementation of {@link #shouldApplyTo(HttpServletRequest, Object)}
37+
* base class implementation of {@code #shouldApplyTo(HttpServletRequest, Object)}
3838
* passing the bean of the {@code HandlerMethod}. Otherwise returns {@code false}.
3939
*/
4040
@Override
@@ -54,8 +54,7 @@ else if (handler instanceof HandlerMethod) {
5454

5555
@Override
5656
protected final ModelAndView doResolveException(
57-
HttpServletRequest request, HttpServletResponse response,
58-
Object handler, Exception ex) {
57+
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
5958

6059
return doResolveHandlerMethodException(request, response, (HandlerMethod) handler, ex);
6160
}
@@ -75,7 +74,6 @@ protected final ModelAndView doResolveException(
7574
* @return a corresponding ModelAndView to forward to, or {@code null} for default processing
7675
*/
7776
protected abstract ModelAndView doResolveHandlerMethodException(
78-
HttpServletRequest request, HttpServletResponse response,
79-
HandlerMethod handlerMethod, Exception ex);
77+
HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception ex);
8078

8179
}

0 commit comments

Comments
 (0)