Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -21,15 +21,19 @@ import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Extension of {@link HttpEntity} that adds a {@link HttpStatus} status code.
|
||||
* Used in {@code RestTemplate} as well {@code @Controller} methods.
|
||||
*
|
||||
* <p>Returned by {@link org.springframework.web.client.RestTemplate#getForEntity}:
|
||||
* <p>In {@code RestTemplate}, this class is returned by
|
||||
* {@link org.springframework.web.client.RestTemplate#getForEntity getForEntity()} and
|
||||
* {@link org.springframework.web.client.RestTemplate#exchange exchange()}:
|
||||
* <pre class="code">
|
||||
* ResponseEntity<String> entity = template.getForEntity("http://example.com", String.class);
|
||||
* String body = entity.getBody();
|
||||
* MediaType contentType = entity.getHeaders().getContentType();
|
||||
* HttpStatus statusCode = entity.getStatusCode();
|
||||
* </pre>
|
||||
* <p>Can also be used in Spring MVC, as a return value from a @Controller method:
|
||||
*
|
||||
* <p>Can also be used in Spring MVC, as the return value from a @Controller method:
|
||||
* <pre class="code">
|
||||
* @RequestMapping("/handle")
|
||||
* public ResponseEntity<String> handle() {
|
||||
|
||||
@@ -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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.server;
|
||||
|
||||
/**
|
||||
@@ -39,17 +40,17 @@ public interface ServerHttpAsyncRequestControl {
|
||||
void start(long timeout);
|
||||
|
||||
/**
|
||||
* Whether asynchronous request processing has been started.
|
||||
* Return whether asynchronous request processing has been started.
|
||||
*/
|
||||
boolean isStarted();
|
||||
|
||||
/**
|
||||
* Causes asynchronous request processing to be completed.
|
||||
* Mark asynchronous request processing as completed.
|
||||
*/
|
||||
void complete();
|
||||
|
||||
/**
|
||||
* Whether asynchronous request processing has been completed.
|
||||
* Return whether asynchronous request processing has been completed.
|
||||
*/
|
||||
boolean isCompleted();
|
||||
|
||||
|
||||
@@ -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,6 +37,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
|
||||
private static long NO_TIMEOUT_VALUE = Long.MIN_VALUE;
|
||||
|
||||
|
||||
private final ServletServerHttpRequest request;
|
||||
|
||||
private final ServletServerHttpResponse response;
|
||||
@@ -52,7 +53,6 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
* respectively.
|
||||
*/
|
||||
public ServletServerHttpAsyncRequestControl(ServletServerHttpRequest request, ServletServerHttpResponse response) {
|
||||
|
||||
Assert.notNull(request, "request is required");
|
||||
Assert.notNull(response, "response is required");
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return ((this.asyncContext != null) && this.request.getServletRequest().isAsyncStarted());
|
||||
return (this.asyncContext != null && this.request.getServletRequest().isAsyncStarted());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,9 +84,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
|
||||
@Override
|
||||
public void start(long timeout) {
|
||||
|
||||
Assert.state(!isCompleted(), "Async processing has already completed");
|
||||
|
||||
if (isStarted()) {
|
||||
return;
|
||||
}
|
||||
@@ -109,6 +107,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Implementation of AsyncListener methods
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -120,12 +119,15 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartAsync(AsyncEvent event) throws IOException { }
|
||||
public void onStartAsync(AsyncEvent event) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(AsyncEvent event) throws IOException { }
|
||||
public void onError(AsyncEvent event) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout(AsyncEvent event) throws IOException { }
|
||||
public void onTimeout(AsyncEvent event) throws IOException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
|
||||
* {@link ServerHttpRequest} implementation that is based on a {@link HttpServletRequest}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
|
||||
Reference in New Issue
Block a user