Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -129,7 +129,7 @@ public abstract class StreamUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a variant of the given {@link InputStream} where calling
|
||||
* Return a variant of the given {@link InputStream} where calling
|
||||
* {@link InputStream#close() close()} has no effect.
|
||||
* @param in the InputStream to decorate
|
||||
* @return a version of the InputStream that ignores calls to close
|
||||
@@ -140,7 +140,7 @@ public abstract class StreamUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a variant of the given {@link OutputStream} where calling
|
||||
* Return a variant of the given {@link OutputStream} where calling
|
||||
* {@link OutputStream#close() close()} has no effect.
|
||||
* @param out the OutputStream to decorate
|
||||
* @return a version of the OutputStream that ignores calls to close
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -22,22 +22,30 @@ import java.net.URI;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* Wrapper for a {@link ClientHttpRequestFactory} that buffers all outgoing and incoming streams in memory.
|
||||
* Wrapper for a {@link ClientHttpRequestFactory} that buffers
|
||||
* all outgoing and incoming streams in memory.
|
||||
*
|
||||
* <p>Using this wrapper allows for multiple reads of the {@linkplain ClientHttpResponse#getBody() response body}.
|
||||
* <p>Using this wrapper allows for multiple reads of the
|
||||
* @linkplain ClientHttpResponse#getBody() response body}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.1
|
||||
*/
|
||||
public class BufferingClientHttpRequestFactory extends AbstractClientHttpRequestFactoryWrapper {
|
||||
|
||||
/**
|
||||
* Create a buffering wrapper for the given {@link ClientHttpRequestFactory}.
|
||||
* @param requestFactory the target request factory to wrap
|
||||
*/
|
||||
public BufferingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory) {
|
||||
super(requestFactory);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory)
|
||||
throws IOException {
|
||||
|
||||
ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod);
|
||||
if (shouldBuffer(uri, httpMethod)) {
|
||||
return new BufferingClientHttpRequestWrapper(request);
|
||||
@@ -48,11 +56,10 @@ public class BufferingClientHttpRequestFactory extends AbstractClientHttpRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the request/response exchange for the given URI and method should be buffered in memory.
|
||||
*
|
||||
* <p>Default implementation returns {@code true} for all URIs and methods. Subclasses can override this method to
|
||||
* change this behavior.
|
||||
*
|
||||
* Indicates whether the request/response exchange for the given URI and method
|
||||
* should be buffered in memory.
|
||||
* <p>The default implementation returns {@code true} for all URIs and methods.
|
||||
* Subclasses can override this method to change this behavior.
|
||||
* @param uri the URI
|
||||
* @param httpMethod the method
|
||||
* @return {@code true} if the exchange should be buffered; {@code false} otherwise
|
||||
@@ -60,4 +67,5 @@ public class BufferingClientHttpRequestFactory extends AbstractClientHttpRequest
|
||||
protected boolean shouldBuffer(URI uri, HttpMethod httpMethod) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -21,7 +21,6 @@ import java.net.URI;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -36,7 +35,6 @@ final class BufferingClientHttpRequestWrapper extends AbstractBufferingClientHtt
|
||||
|
||||
|
||||
BufferingClientHttpRequestWrapper(ClientHttpRequest request) {
|
||||
Assert.notNull(request, "'request' must not be null");
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -25,8 +25,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* Simple implementation of {@link ClientHttpResponse} that reads the response's body into memory,
|
||||
* thus allowing for multiple invocations of {@link #getBody()}.
|
||||
* Simple implementation of {@link ClientHttpResponse} that reads the response's body
|
||||
* into memory, thus allowing for multiple invocations of {@link #getBody()}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -27,8 +27,8 @@ import java.lang.annotation.Target;
|
||||
* handler methods. Provides consistent style between Servlet and Portlet
|
||||
* environments, with the semantics adapting to the concrete environment.
|
||||
*
|
||||
* <p>Handler methods which are annotated with this annotation are allowed
|
||||
* to have very flexible signatures. They may have arguments of the following
|
||||
* <p>Handler methods which are annotated with this annotation are allowed to
|
||||
* have very flexible signatures. They may have parameters of the following
|
||||
* types, in arbitrary order:
|
||||
* <ul>
|
||||
* <li>An exception argument: declared as a general Exception or as a more
|
||||
@@ -48,8 +48,9 @@ import java.lang.annotation.Target;
|
||||
* As a consequence, such an argument will never be {@code null}.
|
||||
* <i>Note that session access may not be thread-safe, in particular in a
|
||||
* Servlet environment: Consider switching the
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#setSynchronizeOnSession "synchronizeOnSession"}
|
||||
* flag to "true" if multiple requests are allowed to access a session concurrently.</i>
|
||||
* {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#setSynchronizeOnSession
|
||||
* "synchronizeOnSession"} flag to "true" if multiple requests are allowed to
|
||||
* access a session concurrently.</i>
|
||||
* <li>{@link org.springframework.web.context.request.WebRequest} or
|
||||
* {@link org.springframework.web.context.request.NativeWebRequest}.
|
||||
* Allows for generic request parameter access as well as request/session
|
||||
@@ -69,8 +70,8 @@ import java.lang.annotation.Target;
|
||||
* <p>The following return types are supported for handler methods:
|
||||
* <ul>
|
||||
* <li>A {@code ModelAndView} object (Servlet MVC or Portlet MVC).
|
||||
* <li>A {@link org.springframework.ui.Model Model} object, with the view name
|
||||
* implicitly determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}.
|
||||
* <li>A {@link org.springframework.ui.Model} object, with the view name implicitly
|
||||
* determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}.
|
||||
* <li>A {@link java.util.Map} object for exposing a model,
|
||||
* with the view name implicitly determined through a
|
||||
* {@link org.springframework.web.servlet.RequestToViewNameTranslator}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -38,8 +38,8 @@ import java.util.concurrent.Callable;
|
||||
* details see the note on the new support classes added in Spring MVC 3.1
|
||||
* further below.
|
||||
*
|
||||
* <p>Handler methods which are annotated with this annotation are allowed
|
||||
* to have very flexible signatures. They may have arguments of the following
|
||||
* <p>Handler methods which are annotated with this annotation are allowed to
|
||||
* have very flexible signatures. They may have parameters of the following
|
||||
* types, in arbitrary order (except for validation results, which need to
|
||||
* follow right after the corresponding command object, if desired):
|
||||
* <ul>
|
||||
@@ -57,8 +57,9 @@ import java.util.concurrent.Callable;
|
||||
* As a consequence, such an argument will never be {@code null}.
|
||||
* <i>Note that session access may not be thread-safe, in particular in a
|
||||
* Servlet environment: Consider switching the
|
||||
* {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#setSynchronizeOnSession "synchronizeOnSession"}
|
||||
* flag to "true" if multiple requests are allowed to access a session concurrently.</i>
|
||||
* {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#setSynchronizeOnSession
|
||||
* "synchronizeOnSession"} flag to "true" if multiple requests are allowed to
|
||||
* access a session concurrently.</i>
|
||||
* <li>{@link org.springframework.web.context.request.WebRequest} or
|
||||
* {@link org.springframework.web.context.request.NativeWebRequest}.
|
||||
* Allows for generic request parameter access as well as request/session
|
||||
@@ -160,7 +161,7 @@ import java.util.concurrent.Callable;
|
||||
* context path, and the literal part of the servlet mapping.
|
||||
* </ul>
|
||||
*
|
||||
* <p><strong>Note:</strong> JDK 1.8's {@code java.util.Optional} is supported
|
||||
* <p><strong>Note:</strong> Java 8's {@code java.util.Optional} is supported
|
||||
* as a method parameter type with annotations that provide a {@code required}
|
||||
* attribute (e.g. {@code @RequestParam}, {@code @RequestHeader}, etc.). The use
|
||||
* of {@code java.util.Optional} in those cases is equivalent to having
|
||||
@@ -171,8 +172,8 @@ import java.util.concurrent.Callable;
|
||||
* <li>A {@code ModelAndView} object (Servlet MVC or Portlet MVC),
|
||||
* with the model implicitly enriched with command objects and the results
|
||||
* of {@link ModelAttribute @ModelAttribute} annotated reference data accessor methods.
|
||||
* <li>A {@link org.springframework.ui.Model Model} object, with the view name
|
||||
* implicitly determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}
|
||||
* <li>A {@link org.springframework.ui.Model Model} object, with the view name implicitly
|
||||
* determined through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}
|
||||
* and the model implicitly enriched with command objects and the results
|
||||
* of {@link ModelAttribute @ModelAttribute} annotated reference data accessor methods.
|
||||
* <li>A {@link java.util.Map} object for exposing a model,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -191,7 +191,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||
* Filter out undesired attributes from the given model.
|
||||
* The return value can be either another {@link Map} or a single value object.
|
||||
* <p>The default implementation removes {@link BindingResult} instances and entries
|
||||
* not included in the {@link #setRenderedAttributes renderedAttributes} property.
|
||||
* not included in the {@link #setModelKeys renderedAttributes} property.
|
||||
* @param model the model, as passed on to {@link #renderMergedOutputModel}
|
||||
* @return the value to be rendered
|
||||
*/
|
||||
@@ -230,9 +230,10 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||
if (this.jsonPrefix != null) {
|
||||
generator.writeRaw(this.jsonPrefix);
|
||||
}
|
||||
|
||||
String jsonpFunction = null;
|
||||
if (object instanceof MappingJacksonValue) {
|
||||
jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction();
|
||||
jsonpFunction = ((MappingJacksonValue) object).getJsonpFunction();
|
||||
}
|
||||
if (jsonpFunction != null) {
|
||||
generator.writeRaw(jsonpFunction + "(" );
|
||||
@@ -243,7 +244,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||
protected void writeSuffix(JsonGenerator generator, Object object) throws IOException {
|
||||
String jsonpFunction = null;
|
||||
if (object instanceof MappingJacksonValue) {
|
||||
jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction();
|
||||
jsonpFunction = ((MappingJacksonValue) object).getJsonpFunction();
|
||||
}
|
||||
if (jsonpFunction != null) {
|
||||
generator.writeRaw(");");
|
||||
|
||||
Reference in New Issue
Block a user