@Async docs explicitly mention ListenableFuture and CompletableFuture

Issue: SPR-14881
This commit is contained in:
Juergen Hoeller
2016-11-04 12:54:24 +01:00
parent cd398ed9e4
commit 8df45dd274
2 changed files with 44 additions and 18 deletions

View File

@@ -29,12 +29,18 @@ import java.lang.annotation.Target;
*
* <p>In terms of target method signatures, any parameter types are supported.
* However, the return type is constrained to either {@code void} or
* {@link java.util.concurrent.Future}. In the latter case, the {@code Future} handle
* returned from the proxy will be an actual asynchronous {@code Future} that can be used
* to track the result of the asynchronous method execution. However, since the
* target method needs to implement the same signature, it will have to return
* a temporary {@code Future} handle that just passes the return value through: e.g.
* Spring's {@link AsyncResult} or EJB 3.1's {@link javax.ejb.AsyncResult}.
* {@link java.util.concurrent.Future}. In the latter case, you may declare the
* more specific {@link org.springframework.util.concurrent.ListenableFuture} or
* {@link java.util.concurrent.CompletableFuture} types which allow for richer
* interaction with the asynchronous task and for immediate composition with
* further processing steps.
*
* <p>A {@code Future} handle returned from the proxy will be an actual asynchronous
* {@code Future} that can be used to track the result of the asynchronous method
* execution. However, since the target method needs to implement the same signature,
* it will have to return a temporary {@code Future} handle that just passes a value
* through: e.g. Spring's {@link AsyncResult}, EJB 3.1's {@link javax.ejb.AsyncResult},
* or {@link java.util.concurrent.CompletableFuture#completedFuture(Object)}.
*
* @author Juergen Hoeller
* @author Chris Beams