Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.0
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest(java.net.URI, org.springframework.http.HttpMethod)
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest
|
||||
*/
|
||||
final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||
|
||||
@@ -47,13 +47,16 @@ final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsync
|
||||
|
||||
private final AsyncListenableTaskExecutor taskExecutor;
|
||||
|
||||
|
||||
SimpleBufferingAsyncClientHttpRequest(HttpURLConnection connection,
|
||||
boolean outputStreaming, AsyncListenableTaskExecutor taskExecutor) {
|
||||
|
||||
this.connection = connection;
|
||||
this.outputStreaming = outputStreaming;
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.connection.getRequestMethod());
|
||||
@@ -72,7 +75,8 @@ final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsync
|
||||
@Override
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(
|
||||
final HttpHeaders headers, final byte[] bufferedOutput) throws IOException {
|
||||
return taskExecutor.submitListenable(new Callable<ClientHttpResponse>() {
|
||||
|
||||
return this.taskExecutor.submitListenable(new Callable<ClientHttpResponse>() {
|
||||
@Override
|
||||
public ClientHttpResponse call() throws Exception {
|
||||
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
|
||||
@@ -81,11 +85,9 @@ final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsync
|
||||
connection.addRequestProperty(headerName, headerValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (connection.getDoOutput() && outputStreaming) {
|
||||
connection.setFixedLengthStreamingMode(bufferedOutput.length);
|
||||
}
|
||||
|
||||
connection.connect();
|
||||
if (connection.getDoOutput()) {
|
||||
FileCopyUtils.copy(bufferedOutput, connection.getOutputStream());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -33,13 +33,12 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.http.client.ClientHttpRequest} implementation that uses
|
||||
* standard J2SE facilities to execute streaming requests. Created via the {@link
|
||||
* standard Java facilities to execute streaming requests. Created via the {@link
|
||||
* org.springframework.http.client.SimpleClientHttpRequestFactory}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest(java.net.URI,
|
||||
* org.springframework.http.HttpMethod)
|
||||
* @since 3.0
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest
|
||||
*/
|
||||
final class SimpleStreamingAsyncClientHttpRequest extends AbstractAsyncClientHttpRequest {
|
||||
|
||||
@@ -53,14 +52,17 @@ final class SimpleStreamingAsyncClientHttpRequest extends AbstractAsyncClientHtt
|
||||
|
||||
private final AsyncListenableTaskExecutor taskExecutor;
|
||||
|
||||
|
||||
SimpleStreamingAsyncClientHttpRequest(HttpURLConnection connection, int chunkSize,
|
||||
boolean outputStreaming, AsyncListenableTaskExecutor taskExecutor) {
|
||||
|
||||
this.connection = connection;
|
||||
this.chunkSize = chunkSize;
|
||||
this.outputStreaming = outputStreaming;
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.connection.getRequestMethod());
|
||||
@@ -106,8 +108,7 @@ final class SimpleStreamingAsyncClientHttpRequest extends AbstractAsyncClientHtt
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers)
|
||||
throws IOException {
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
|
||||
return taskExecutor.submitListenable(new Callable<ClientHttpResponse>() {
|
||||
@Override
|
||||
public ClientHttpResponse call() throws Exception {
|
||||
|
||||
@@ -266,13 +266,11 @@ import java.util.concurrent.Callable;
|
||||
@Mapping
|
||||
public @interface RequestMapping {
|
||||
|
||||
|
||||
/**
|
||||
* Assign a name to this mapping.
|
||||
* <p><b>Supported at the method and also at type level!</b>
|
||||
* When used on both levels, a combined name is derived by
|
||||
* concatenation with "#" as separator.
|
||||
*
|
||||
* <p><b>Supported at the type level as well as at the method level!</b>
|
||||
* When used on both levels, a combined name is derived by concatenation
|
||||
* with "#" as separator.
|
||||
* @see org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder
|
||||
* @see org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user