Top Description Fields Constructors Methods
org.springframework.web.context.request.async

public Class WebAsyncTask<V>

extends Object
implements BeanFactoryAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.Aware
Type Parameters
<V>
the value type
Imports
java.util.concurrent.Callable, org.springframework.beans.factory.BeanFactory, .BeanFactoryAware, org.springframework.core.task.AsyncTaskExecutor, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.context.request.NativeWebRequest

Holder for a Callable, a timeout value, and a task executor.
Authors
Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
Since
3.2

Field Summary

Modifier and TypeField and Description
private BeanFactory
private final Callable<V>
private Runnable
private Callable<V>
private final AsyncTaskExecutor
private final String
private final Long
private Callable<V>

Constructor Summary

AccessConstructor and Description
public
WebAsyncTask(Callable<V>
the callable for concurrent handling
callable
)

Create a WebAsyncTask wrapping the given Callable.

public
WebAsyncTask(long
a timeout value in milliseconds
timeout
,
Callable<V>
the callable for concurrent handling
callable
)

Create a WebAsyncTask with a timeout value and a Callable.

public
WebAsyncTask(Long
the timeout value in milliseconds; ignored if null
timeout
,
String
the name of an executor bean to use
executorName
,
Callable<V>
the callable for concurrent handling
callable
)

Create a WebAsyncTask with a timeout value, an executor name, and a Callable.

public
WebAsyncTask(Long
the timeout value in milliseconds; ignored if null
timeout
,
AsyncTaskExecutor
the executor to use
executor
,
Callable<V>
the callable for concurrent handling
callable
)

Create a WebAsyncTask with a timeout value, an executor instance, and a Callable.

Method Summary

Modifier and TypeMethod and Description
public Callable<?>
getCallable()

Return the Callable to use for concurrent handling (never null).

public AsyncTaskExecutor
getExecutor()

Return the AsyncTaskExecutor to use for concurrent handling, or null if none specified.

pack-priv CallableProcessingInterceptor
public Long
getTimeout()

Return the timeout value in milliseconds, or null if no timeout is set.

public void
onCompletion(Runnable callback)

Register code to invoke when the async request completes.

public void
onError(Callable<V> callback)

Register code to invoke for an error during async request processing.

public void
onTimeout(Callable<V> callback)

Register code to invoke when the async request times out.

public void
setBeanFactory(BeanFactory
owning BeanFactory (never null). The bean can immediately call methods on the factory.
beanFactory
)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

A BeanFactory to use for resolving an executor name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanFactoryback to summary
private BeanFactory beanFactory
callableback to summary
private final Callable<V> callable
completionCallbackback to summary
private Runnable completionCallback
errorCallbackback to summary
private Callable<V> errorCallback
executorback to summary
private final AsyncTaskExecutor executor
Annotations
@Nullable
executorNameback to summary
private final String executorName
Annotations
@Nullable
timeoutback to summary
private final Long timeout
Annotations
@Nullable
timeoutCallbackback to summary
private Callable<V> timeoutCallback

Constructor Detail

WebAsyncTaskback to summary
public WebAsyncTask(Callable<V> callable)

Create a WebAsyncTask wrapping the given Callable.

Parameters
callable:Callable<V>

the callable for concurrent handling

WebAsyncTaskback to summary
public WebAsyncTask(long timeout, Callable<V> callable)

Create a WebAsyncTask with a timeout value and a Callable.

Parameters
timeout:long

a timeout value in milliseconds

callable:Callable<V>

the callable for concurrent handling

WebAsyncTaskback to summary
public WebAsyncTask(Long timeout, String executorName, Callable<V> callable)

Create a WebAsyncTask with a timeout value, an executor name, and a Callable.

Parameters
timeout:Long

the timeout value in milliseconds; ignored if null

executorName:String

the name of an executor bean to use

callable:Callable<V>

the callable for concurrent handling

WebAsyncTaskback to summary
public WebAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable<V> callable)

Create a WebAsyncTask with a timeout value, an executor instance, and a Callable.

Parameters
timeout:Long

the timeout value in milliseconds; ignored if null

executor:AsyncTaskExecutor

the executor to use

callable:Callable<V>

the callable for concurrent handling

Method Detail

getCallableback to summary
public Callable<?> getCallable()

Return the Callable to use for concurrent handling (never null).

getExecutorback to summary
public AsyncTaskExecutor getExecutor()

Return the AsyncTaskExecutor to use for concurrent handling, or null if none specified.

Annotations
@Nullable
getInterceptorback to summary
pack-priv CallableProcessingInterceptor getInterceptor()
getTimeoutback to summary
public Long getTimeout()

Return the timeout value in milliseconds, or null if no timeout is set.

Annotations
@Nullable
onCompletionback to summary
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.

onErrorback to summary
public void onError(Callable<V> callback)

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 an Exception or return RESULT_NONE.

Since
5.0
onTimeoutback to summary
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 an Exception or return RESULT_NONE.

setBeanFactoryback to summary
public void setBeanFactory(BeanFactory beanFactory)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

A BeanFactory to use for resolving an executor name.

This factory reference will automatically be set when WebAsyncTask is used within a Spring MVC controller.

Parameters
beanFactory:BeanFactory

Doc from org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

owning BeanFactory (never null). The bean can immediately call methods on the factory.

Annotations
@Override