public class WebAsyncTask<V>
extends java.lang.Object
Callable
, a timeout value, and a task executor.Modifier and Type | Field and Description |
---|---|
private BeanFactory |
beanFactory |
private java.util.concurrent.Callable<V> |
callable |
private java.lang.Runnable |
completionCallback |
private AsyncTaskExecutor |
executor |
private java.lang.String |
executorName |
private java.lang.Long |
timeout |
private java.util.concurrent.Callable<V> |
timeoutCallback |
Modifier | Constructor and Description |
---|---|
|
WebAsyncTask(java.util.concurrent.Callable<V> callable)
Create an
WebAsyncTask wrapping the given Callable . |
|
WebAsyncTask(java.lang.Long timeout,
AsyncTaskExecutor executor,
java.util.concurrent.Callable<V> callable)
Create an
WebAsyncTask with a timeout value, an executor instance, and a Callable. |
private |
WebAsyncTask(java.lang.Long timeout,
AsyncTaskExecutor executor,
java.lang.String executorName,
java.util.concurrent.Callable<V> callable) |
|
WebAsyncTask(long timeout,
java.util.concurrent.Callable<V> callable)
Create an
WebAsyncTask with a timeout value and a Callable . |
|
WebAsyncTask(java.lang.Long timeout,
java.lang.String executorName,
java.util.concurrent.Callable<V> callable)
Create an
WebAsyncTask with a timeout value, an executor name, and a Callable . |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.Callable<?> |
getCallable()
Return the
Callable to use for concurrent handling, never null . |
AsyncTaskExecutor |
getExecutor()
Return the AsyncTaskExecutor to use for concurrent handling, or
null . |
(package private) CallableProcessingInterceptor |
getInterceptor() |
java.lang.Long |
getTimeout()
Return the timeout value in milliseconds or
null if not value is set. |
void |
onCompletion(java.lang.Runnable callback)
Register code to invoke when the async request completes.
|
void |
onTimeout(java.util.concurrent.Callable<V> callback)
Register code to invoke when the async request times out.
|
void |
setBeanFactory(BeanFactory beanFactory)
A
BeanFactory to use to resolve an executor name. |
private final java.util.concurrent.Callable<V> callable
private final java.lang.Long timeout
private final java.lang.String executorName
private final AsyncTaskExecutor executor
private java.util.concurrent.Callable<V> timeoutCallback
private java.lang.Runnable completionCallback
private BeanFactory beanFactory
public WebAsyncTask(java.util.concurrent.Callable<V> callable)
WebAsyncTask
wrapping the given Callable
.callable
- the callable for concurrent handlingpublic WebAsyncTask(long timeout, java.util.concurrent.Callable<V> callable)
WebAsyncTask
with a timeout value and a Callable
.timeout
- timeout value in millisecondscallable
- the callable for concurrent handlingpublic WebAsyncTask(java.lang.Long timeout, java.lang.String executorName, java.util.concurrent.Callable<V> callable)
WebAsyncTask
with a timeout value, an executor name, and a Callable
.timeout
- timeout value in milliseconds; ignored if null
callable
- the callable for concurrent handlingpublic WebAsyncTask(java.lang.Long timeout, AsyncTaskExecutor executor, java.util.concurrent.Callable<V> callable)
WebAsyncTask
with a timeout value, an executor instance, and a Callable.timeout
- timeout value in milliseconds; ignored if null
callable
- the callable for concurrent handlingprivate WebAsyncTask(java.lang.Long timeout, AsyncTaskExecutor executor, java.lang.String executorName, java.util.concurrent.Callable<V> callable)
public java.util.concurrent.Callable<?> getCallable()
Callable
to use for concurrent handling, never null
.public java.lang.Long getTimeout()
null
if not value is set.public AsyncTaskExecutor getExecutor()
null
.public void setBeanFactory(BeanFactory beanFactory)
BeanFactory
to use to resolve an executor name. Applications are
not expected to have to set this property when WebAsyncTask
is used in a
Spring MVC controller.public void onTimeout(java.util.concurrent.Callable<V> callback)
Callable
has completed. The callback is executed in the same
thread and therefore should return without blocking. It may return an
alternative value to use, including an Exception
or return
RESULT_NONE
.public void onCompletion(java.lang.Runnable callback)
CallableProcessingInterceptor getInterceptor()