Interface ExecutorServices

All Superinterfaces:
Service

public interface ExecutorServices extends Service
Allows a custom TaskExecutor to be provided by the container. By default, Executors.newSingleThreadExecutor() is used. This is a per-deployment service.
Author:
Pete Muir, Jozef Hartinger
  • Method Details

    • getTaskExecutor

      ExecutorService getTaskExecutor()
    • getTimerExecutor

      default ScheduledExecutorService getTimerExecutor()
      Returns a new ScheduledExecutorService instance which will be used for asynchronous observer notification timeout. Can return null in which case the observer notification timeout feature throws an exception.
      Returns:
      ScheduledExecutorService instance or null
      Since:
      3.0
    • invokeAllAndCheckForExceptions

      <T> List<Future<T>> invokeAllAndCheckForExceptions(Collection<? extends Callable<T>> tasks)
      Executes the given tasks and blocks until they all finish. If a task throws an exception, the exception is rethrown by this method. If multiple tasks throw exceptions, there is no guarantee about which of the exceptions is rethrown by this method.
      Type Parameters:
      T - the result type of tasks
      Parameters:
      tasks - the collection of tasks
      Returns:
      A list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed.
    • invokeAllAndCheckForExceptions

      <T> List<Future<T>> invokeAllAndCheckForExceptions(ExecutorServices.TaskFactory<T> factory)
      Executes all the tasks returned from calling ExecutorServices.TaskFactory.createTasks(int) method. The method is called exactly once.If a task throws an exception, the exception is rethrown by this method. If multiple tasks throw exceptions, there is no guarantee about which of the exceptions is rethrown by this method.
      Type Parameters:
      T - the result type of tasks
      Parameters:
      factory - factory capable of creating tasks
      Returns:
      A list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed.