类 WebAsyncTask<V>
- java.lang.Object
- org.springframework.web.context.request.async.WebAsyncTask<V>
- 所有已实现的接口:
Aware
,BeanFactoryAware
public class WebAsyncTask<V> extends Object implements BeanFactoryAware
Holder for aCallable
, a timeout value, and a task executor.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
构造器概要
构造器 构造器 说明 WebAsyncTask(long timeout, Callable<V> callable)
Create aWebAsyncTask
with a timeout value and aCallable
.WebAsyncTask(Long timeout, String executorName, Callable<V> callable)
Create aWebAsyncTask
with a timeout value, an executor name, and aCallable
.WebAsyncTask(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
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Callable<?>
getCallable()
Return theCallable
to use for concurrent handling (nevernull
).AsyncTaskExecutor
getExecutor()
Return the AsyncTaskExecutor to use for concurrent handling, ornull
if none specified.Long
getTimeout()
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
onTimeout(Callable<V> callback)
Register code to invoke when the async request times out.void
setBeanFactory(BeanFactory beanFactory)
ABeanFactory
to use for resolving an executor name.
构造器详细资料
WebAsyncTask
public WebAsyncTask(Callable<V> callable)
Create aWebAsyncTask
wrapping the givenCallable
.- 参数:
callable
- the callable for concurrent handling
WebAsyncTask
public WebAsyncTask(long timeout, Callable<V> callable)
Create aWebAsyncTask
with a timeout value and aCallable
.- 参数:
timeout
- a timeout value in millisecondscallable
- the callable for concurrent handling
WebAsyncTask
public WebAsyncTask(Long timeout, String executorName, Callable<V> callable)
Create aWebAsyncTask
with a timeout value, an executor name, and aCallable
.- 参数:
timeout
- timeout value in milliseconds; ignored ifnull
executorName
- the name of an executor bean to usecallable
- the callable for concurrent handling
WebAsyncTask
public WebAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable<V> callable)
Create aWebAsyncTask
with a timeout value, an executor instance, and a Callable.- 参数:
timeout
- timeout value in milliseconds; ignored ifnull
executor
- the executor to usecallable
- the callable for concurrent handling
方法详细资料
getCallable
public Callable<?> getCallable()
Return theCallable
to use for concurrent handling (nevernull
).
getTimeout
public Long getTimeout()
Return the timeout value in milliseconds, ornull
if no timeout is set.
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
ABeanFactory
to use for resolving an executor name.This factory reference will automatically be set when
WebAsyncTask
is used within a Spring MVC controller.- 指定者:
setBeanFactory
在接口中BeanFactoryAware
- 参数:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException
getExecutor
public AsyncTaskExecutor getExecutor()
Return the AsyncTaskExecutor to use for concurrent handling, ornull
if none specified.
onTimeout
public void onTimeout(Callable<V> callback)
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
.
onCompletion
public void onCompletion(Runnable callback)
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.