Class WebAsyncTask<V>
- Type Parameters:
V
- the value type
- All Implemented Interfaces:
Aware
,BeanFactoryAware
Callable
, a timeout value, and a task executor.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
-
Constructor Summary
ConstructorDescriptionWebAsyncTask
(long timeout, Callable<V> callable) Create aWebAsyncTask
with a timeout value and aCallable
.Create aWebAsyncTask
with a timeout value, an executor name, and aCallable
.WebAsyncTask
(@Nullable Long timeout, AsyncTaskExecutor executor, Callable<V> callable) Create aWebAsyncTask
with a timeout value, an executor instance, and a Callable.WebAsyncTask
(Callable<V> callable) Create aWebAsyncTask
wrapping the givenCallable
. -
Method Summary
Modifier and TypeMethodDescriptionCallable<?>
Return theCallable
to use for concurrent handling (nevernull
).Return the AsyncTaskExecutor to use for concurrent handling, ornull
if none specified.Return the timeout value in milliseconds, ornull
if no timeout is set.void
onCompletion
(Runnable callback) Register code to invoke when the async request completes.void
Register code to invoke for an error during async request processing.void
Register code to invoke when the async request times out.void
setBeanFactory
(BeanFactory beanFactory) ABeanFactory
to use for resolving an executor name.
-
Constructor Details
-
WebAsyncTask
Create aWebAsyncTask
wrapping the givenCallable
.- Parameters:
callable
- the callable for concurrent handling
-
WebAsyncTask
Create aWebAsyncTask
with a timeout value and aCallable
.- Parameters:
timeout
- a timeout value in millisecondscallable
- the callable for concurrent handling
-
WebAsyncTask
Create aWebAsyncTask
with a timeout value, an executor name, and aCallable
.- Parameters:
timeout
- the timeout value in milliseconds; ignored ifnull
executorName
- the name of an executor bean to usecallable
- the callable for concurrent handling
-
WebAsyncTask
Create aWebAsyncTask
with a timeout value, an executor instance, and a Callable.- Parameters:
timeout
- the timeout value in milliseconds; ignored ifnull
executor
- the executor to usecallable
- the callable for concurrent handling
-
-
Method Details
-
getCallable
Return theCallable
to use for concurrent handling (nevernull
). -
getTimeout
Return the timeout value in milliseconds, ornull
if no timeout is set. -
setBeanFactory
ABeanFactory
to use for resolving an executor name.This factory reference will automatically be set when
WebAsyncTask
is used within a Spring MVC controller.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
-
getExecutor
Return the AsyncTaskExecutor to use for concurrent handling, ornull
if none specified. -
onTimeout
Register code to invoke when the async request times out.This method is called from a container thread when an async request times out before the
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 anException
or returnRESULT_NONE
. -
onError
Register code to invoke for an error during async request processing.This method is called from a container thread when an error occurred while processing an async request before the
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 anException
or returnRESULT_NONE
.- Since:
- 5.0
-
onCompletion
Register code to invoke when the async request completes.This method is called from a container thread when an async request completed for any reason, including timeout and network error.
-