类 WebAsyncTask<V>

java.lang.Object
cn.taketoday.web.context.async.WebAsyncTask<V>
类型参数:
V - the value type
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.beans.factory.BeanFactoryAware

public class WebAsyncTask<V> extends Object implements cn.taketoday.beans.factory.BeanFactoryAware
Holder for a Callable, a timeout value, and a task executor.
从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Juergen Hoeller
  • 字段详细资料

    • callable

      private final Callable<V> callable
    • timeout

      private Long timeout
    • executor

      private cn.taketoday.core.task.AsyncTaskExecutor executor
    • executorName

      private String executorName
    • beanFactory

      private cn.taketoday.beans.factory.BeanFactory beanFactory
    • timeoutCallback

      private Callable<V> timeoutCallback
    • errorCallback

      private Callable<V> errorCallback
    • completionCallback

      private Runnable completionCallback
  • 构造器详细资料

    • WebAsyncTask

      public WebAsyncTask(Callable<V> callable)
      Create a WebAsyncTask wrapping the given Callable.
      参数:
      callable - the callable for concurrent handling
    • WebAsyncTask

      public WebAsyncTask(@Nullable Long timeout, Callable<V> callable)
      Create a WebAsyncTask with a timeout value and a Callable.
      参数:
      timeout - a timeout value in milliseconds
      callable - the callable for concurrent handling
    • WebAsyncTask

      public WebAsyncTask(@Nullable Long timeout, String executorName, Callable<V> callable)
      Create a WebAsyncTask with a timeout value, an executor name, and a Callable.
      参数:
      timeout - the timeout value in milliseconds; ignored if null
      executorName - the name of an executor bean to use
      callable - the callable for concurrent handling
    • WebAsyncTask

      public WebAsyncTask(@Nullable Long timeout, cn.taketoday.core.task.AsyncTaskExecutor executor, Callable<V> callable)
      Create a WebAsyncTask with a timeout value, an executor instance, and a Callable.
      参数:
      timeout - the timeout value in milliseconds; ignored if null
      executor - the executor to use
      callable - the callable for concurrent handling
  • 方法详细资料

    • getCallable

      public Callable<?> getCallable()
      Return the Callable to use for concurrent handling (never null).
    • getTimeout

      @Nullable public Long getTimeout()
      Return the timeout value in milliseconds, or null if no timeout is set.
    • setBeanFactory

      public void setBeanFactory(cn.taketoday.beans.factory.BeanFactory beanFactory)
      A BeanFactory to use for resolving an executor name.

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

      指定者:
      setBeanFactory 在接口中 cn.taketoday.beans.factory.BeanFactoryAware
    • getExecutor

      @Nullable public cn.taketoday.core.task.AsyncTaskExecutor getExecutor()
      Return the AsyncTaskExecutor to use for concurrent handling, or null 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 an Exception or return RESULT_NONE.

    • onError

      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.

    • 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.

    • getInterceptor