Skip to content

Commit 6256586

Browse files
committed
Polishing
1 parent 4391b29 commit 6256586

File tree

6 files changed

+60
-52
lines changed

6 files changed

+60
-52
lines changed

spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestFactory.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -22,22 +22,30 @@
2222
import org.springframework.http.HttpMethod;
2323

2424
/**
25-
* Wrapper for a {@link ClientHttpRequestFactory} that buffers all outgoing and incoming streams in memory.
25+
* Wrapper for a {@link ClientHttpRequestFactory} that buffers
26+
* all outgoing and incoming streams in memory.
2627
*
27-
* <p>Using this wrapper allows for multiple reads of the {@linkplain ClientHttpResponse#getBody() response body}.
28+
* <p>Using this wrapper allows for multiple reads of the
29+
* @linkplain ClientHttpResponse#getBody() response body}.
2830
*
2931
* @author Arjen Poutsma
3032
* @since 3.1
3133
*/
3234
public class BufferingClientHttpRequestFactory extends AbstractClientHttpRequestFactoryWrapper {
3335

36+
/**
37+
* Create a buffering wrapper for the given {@link ClientHttpRequestFactory}.
38+
* @param requestFactory the target request factory to wrap
39+
*/
3440
public BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory) {
3541
super(requestFactory);
3642
}
3743

44+
3845
@Override
3946
protected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory)
4047
throws IOException {
48+
4149
ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod);
4250
if (shouldBuffer(uri, httpMethod)) {
4351
return new BufferingClientHttpRequestWrapper(request);
@@ -48,16 +56,16 @@ protected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, Client
4856
}
4957

5058
/**
51-
* Indicates whether the request/response exchange for the given URI and method should be buffered in memory.
52-
*
53-
* <p>Default implementation returns {@code true} for all URIs and methods. Subclasses can override this method to
54-
* change this behavior.
55-
*
59+
* Indicates whether the request/response exchange for the given URI and method
60+
* should be buffered in memory.
61+
* <p>The default implementation returns {@code true} for all URIs and methods.
62+
* Subclasses can override this method to change this behavior.
5663
* @param uri the URI
5764
* @param httpMethod the method
5865
* @return {@code true} if the exchange should be buffered; {@code false} otherwise
5966
*/
6067
protected boolean shouldBuffer(URI uri, HttpMethod httpMethod) {
6168
return true;
6269
}
70+
6371
}

spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java

Lines changed: 1 addition & 3 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-2015 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.
@@ -21,7 +21,6 @@
2121

2222
import org.springframework.http.HttpHeaders;
2323
import org.springframework.http.HttpMethod;
24-
import org.springframework.util.Assert;
2524
import org.springframework.util.StreamUtils;
2625

2726
/**
@@ -36,7 +35,6 @@ final class BufferingClientHttpRequestWrapper extends AbstractBufferingClientHtt
3635

3736

3837
BufferingClientHttpRequestWrapper(ClientHttpRequest request) {
39-
Assert.notNull(request, "'request' must not be null");
4038
this.request = request;
4139
}
4240

spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java

Lines changed: 3 additions & 3 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-2015 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.
@@ -25,8 +25,8 @@
2525
import org.springframework.util.StreamUtils;
2626

2727
/**
28-
* Simple implementation of {@link ClientHttpResponse} that reads the response's body into memory,
29-
* thus allowing for multiple invocations of {@link #getBody()}.
28+
* Simple implementation of {@link ClientHttpResponse} that reads the response's body
29+
* into memory, thus allowing for multiple invocations of {@link #getBody()}.
3030
*
3131
* @author Arjen Poutsma
3232
* @since 3.1

spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
* details see the note on the new support classes added in Spring MVC 3.1
4141
* further below.
4242
*
43-
* <p>Handler methods which are annotated with this annotation are allowed
44-
* to have very flexible signatures. They may have arguments of the following
43+
* <p>Handler methods which are annotated with this annotation are allowed to
44+
* have very flexible signatures. They may have parameters of the following
4545
* types, in arbitrary order (except for validation results, which need to
4646
* follow right after the corresponding command object, if desired):
4747
* <ul>
@@ -163,7 +163,7 @@
163163
* context path, and the literal part of the servlet mapping.
164164
* </ul>
165165
*
166-
* <p><strong>Note:</strong> JDK 1.8's {@code java.util.Optional} is supported
166+
* <p><strong>Note:</strong> Java 8's {@code java.util.Optional} is supported
167167
* as a method parameter type with annotations that provide a {@code required}
168168
* attribute (e.g. {@code @RequestParam}, {@code @RequestHeader}, etc.). The use
169169
* of {@code java.util.Optional} in those cases is equivalent to having
@@ -174,8 +174,8 @@
174174
* <li>A {@code ModelAndView} object (Servlet MVC or Portlet MVC),
175175
* with the model implicitly enriched with command objects and the results
176176
* of {@link ModelAttribute @ModelAttribute} annotated reference data accessor methods.
177-
* <li>A {@link org.springframework.ui.Model Model} object, with the view name
178-
* implicitly determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}
177+
* <li>A {@link org.springframework.ui.Model Model} object, with the view name implicitly
178+
* determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}
179179
* and the model implicitly enriched with command objects and the results
180180
* of {@link ModelAttribute @ModelAttribute} annotated reference data accessor methods.
181181
* <li>A {@link java.util.Map} object for exposing a model,

spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ public final Set<String> getModelKeys() {
143143
}
144144

145145
/**
146-
* Set whether to serialize models containing a single attribute as a map or whether to
147-
* extract the single value from the model and serialize it directly.
148-
* <p>The effect of setting this flag is similar to using {@code MappingJackson2HttpMessageConverter}
149-
* with an {@code @ResponseBody} request-handling method.
146+
* Set whether to serialize models containing a single attribute as a map or
147+
* whether to extract the single value from the model and serialize it directly.
148+
* <p>The effect of setting this flag is similar to using
149+
* {@code MappingJackson2HttpMessageConverter} with an {@code @ResponseBody}
150+
* request-handling method.
150151
* <p>Default is {@code false}.
151152
*/
152153
public void setExtractValueFromSingleKeyModel(boolean extractValueFromSingleKeyModel) {
@@ -181,7 +182,7 @@ private String getJsonpParameterValue(HttpServletRequest request) {
181182
* Filter out undesired attributes from the given model.
182183
* The return value can be either another {@link Map} or a single value object.
183184
* <p>The default implementation removes {@link BindingResult} instances and entries
184-
* not included in the {@link #setRenderedAttributes renderedAttributes} property.
185+
* not included in the {@link #setModelKeys renderedAttributes} property.
185186
* @param model the model, as passed on to {@link #renderMergedOutputModel}
186187
* @return the value to be rendered
187188
*/
@@ -221,9 +222,10 @@ protected void writePrefix(JsonGenerator generator, Object object) throws IOExce
221222
if (this.jsonPrefix != null) {
222223
generator.writeRaw(this.jsonPrefix);
223224
}
225+
224226
String jsonpFunction = null;
225227
if (object instanceof MappingJacksonValue) {
226-
jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction();
228+
jsonpFunction = ((MappingJacksonValue) object).getJsonpFunction();
227229
}
228230
if (jsonpFunction != null) {
229231
generator.writeRaw(jsonpFunction + "(" );
@@ -234,7 +236,7 @@ protected void writePrefix(JsonGenerator generator, Object object) throws IOExce
234236
protected void writeSuffix(JsonGenerator generator, Object object) throws IOException {
235237
String jsonpFunction = null;
236238
if (object instanceof MappingJacksonValue) {
237-
jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction();
239+
jsonpFunction = ((MappingJacksonValue) object).getJsonpFunction();
238240
}
239241
if (jsonpFunction != null) {
240242
generator.writeRaw(");");

src/asciidoc/web-mvc.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ controller. When this is the case, for controllers specifically, we recommend
635635
using class-based proxying. This is typically the default choice with controllers.
636636
However if a controller must implement an interface that is not a Spring Context
637637
callback (e.g. `InitializingBean`, `*Aware`, etc), you may need to explicitly
638-
configure class-based proxying. For example with `<tx:annotation-driven />`,
639-
change to `<tx:annotation-driven proxy-target-class="true" />`.
638+
configure class-based proxying. For example with `<tx:annotation-driven/>`,
639+
change to `<tx:annotation-driven proxy-target-class="true"/>`.
640640

641641
[[mvc-ann-requestmapping-31-vs-30]]
642642
==== New Support Classes for @RequestMapping methods in Spring MVC 3.1
@@ -1368,8 +1368,8 @@ the MVC namespace or the MVC Java config see <<mvc-config-enable>> instead.
13681368
13691369
<bean id="marshallingHttpMessageConverter"
13701370
class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
1371-
<property name="marshaller" ref="castorMarshaller" />
1372-
<property name="unmarshaller" ref="castorMarshaller" />
1371+
<property name="marshaller" ref="castorMarshaller"/>
1372+
<property name="unmarshaller" ref="castorMarshaller"/>
13731373
</bean>
13741374
13751375
<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"/>
@@ -1897,9 +1897,9 @@ PropertyEditors required by several of the PetClinic controllers.
18971897
[subs="verbatim,quotes"]
18981898
----
18991899
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
1900-
<property name="cacheSeconds" value="0" />
1900+
<property name="cacheSeconds" value="0"/>
19011901
<property name="webBindingInitializer">
1902-
<bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer" />
1902+
<bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer"/>
19031903
</property>
19041904
</bean>
19051905
----
@@ -4512,7 +4512,7 @@ context defined):
45124512
http://www.springframework.org/schema/mvc
45134513
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
45144514
4515-
<mvc:annotation-driven />
4515+
<mvc:annotation-driven/>
45164516
45174517
</beans>
45184518
----
@@ -4602,7 +4602,7 @@ and override the methods you need:
46024602
}
46034603
----
46044604

4605-
To customize the default configuration of `<mvc:annotation-driven />` check what
4605+
To customize the default configuration of `<mvc:annotation-driven/>` check what
46064606
attributes and sub-elements it supports. You can view the
46074607
http://schema.spring.io/mvc/spring-mvc.xsd[Spring MVC XML schema] or use the code
46084608
completion feature of your IDE to discover what attributes and sub-elements are
@@ -4799,15 +4799,15 @@ And in XML use the `<mvc:interceptors>` element:
47994799
[subs="verbatim"]
48004800
----
48014801
<mvc:interceptors>
4802-
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
4802+
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
48034803
<mvc:interceptor>
48044804
<mvc:mapping path="/**"/>
48054805
<mvc:exclude-mapping path="/admin/**"/>
4806-
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
4806+
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
48074807
</mvc:interceptor>
48084808
<mvc:interceptor>
48094809
<mvc:mapping path="/secure/*"/>
4810-
<bean class="org.example.SecurityInterceptor" />
4810+
<bean class="org.example.SecurityInterceptor"/>
48114811
</mvc:interceptor>
48124812
</mvc:interceptors>
48134813
----
@@ -4858,7 +4858,7 @@ that in turn can be created with a `ContentNegotiationManagerFactoryBean`:
48584858
[source,xml,indent=0]
48594859
[subs="verbatim,quotes"]
48604860
----
4861-
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
4861+
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
48624862
48634863
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
48644864
<property name="favorPathExtension" value="false"/>
@@ -4954,10 +4954,10 @@ And the same in XML:
49544954
<mvc:view-resolvers>
49554955
<mvc:content-negotiation>
49564956
<mvc:default-views>
4957-
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
4957+
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
49584958
</mvc:default-views>
49594959
</mvc:content-negotiation>
4960-
<mvc:jsp />
4960+
<mvc:jsp/>
49614961
</mvc:view-resolvers>
49624962
----
49634963

@@ -4973,14 +4973,14 @@ The MVC namespace provides dedicated elements. For example with FreeMarker:
49734973
<mvc:view-resolvers>
49744974
<mvc:content-negotiation>
49754975
<mvc:default-views>
4976-
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
4976+
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
49774977
</mvc:default-views>
49784978
</mvc:content-negotiation>
4979-
<mvc:freemarker cache="false" />
4979+
<mvc:freemarker cache="false"/>
49804980
</mvc:view-resolvers>
49814981
49824982
<mvc:freemarker-configurer>
4983-
<mvc:template-loader-path location="/freemarker" />
4983+
<mvc:template-loader-path location="/freemarker"/>
49844984
</mvc:freemarker-configurer>
49854985
49864986
----
@@ -5158,7 +5158,7 @@ XML example:
51585158
----
51595159
<mvc:resources mapping="/resources/**" location="/public-resources/">
51605160
<mvc:resource-chain>
5161-
<mvc:resource-cache />
5161+
<mvc:resource-cache/>
51625162
<mvc:resolvers>
51635163
<mvc:version-resolver>
51645164
<mvc:content-version-strategy patterns="/**"/>
@@ -5306,11 +5306,11 @@ And the same in XML, use the `<mvc:path-matching>` element:
53065306
trailing-slash="false"
53075307
registered-suffixes-only="true"
53085308
path-helper="pathHelper"
5309-
path-matcher="pathMatcher" />
5309+
path-matcher="pathMatcher"/>
53105310
</mvc:annotation-driven>
53115311
5312-
<bean id="pathHelper" class="org.example.app.MyPathHelper" />
5313-
<bean id="pathMatcher" class="org.example.app.MyPathMatcher" />
5312+
<bean id="pathHelper" class="org.example.app.MyPathHelper"/>
5313+
<bean id="pathMatcher" class="org.example.app.MyPathMatcher"/>
53145314
----
53155315

53165316

@@ -5373,20 +5373,20 @@ It is also possible to do the same in XML:
53735373
<mvc:annotation-driven>
53745374
<mvc:message-converters>
53755375
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
5376-
<property name="objectMapper" ref="objectMapper" />
5376+
<property name="objectMapper" ref="objectMapper"/>
53775377
</bean>
53785378
<bean class="org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter">
5379-
<property name="objectMapper" ref="xmlMapper" />
5379+
<property name="objectMapper" ref="xmlMapper"/>
53805380
</bean>
53815381
</mvc:message-converters>
53825382
</mvc:annotation-driven>
53835383
53845384
<bean id="objectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"
53855385
p:indentOutput="true"
53865386
p:simpleDateFormat="yyyy-MM-dd"
5387-
p:modulesToInstall="com.fasterxml.jackson.module.paramnames.ParameterNamesModule" />
5387+
p:modulesToInstall="com.fasterxml.jackson.module.paramnames.ParameterNamesModule"/>
53885388
5389-
<bean id="xmlMapper" parent="objectMapper" p:createXmlMapper="true" />
5389+
<bean id="xmlMapper" parent="objectMapper" p:createXmlMapper="true"/>
53905390
----
53915391

53925392

@@ -5470,6 +5470,6 @@ by type and then modifying its properties as necessary. For example:
54705470
}
54715471
----
54725472

5473-
Note that `MyPostProcessor` needs to be included in an `<component scan />` in order for
5473+
Note that `MyPostProcessor` needs to be included in an `<component scan/>` in order for
54745474
it to be detected or if you prefer you can declare it explicitly with an XML bean
54755475
declaration.

0 commit comments

Comments
 (0)