Class ExecutorServiceAdapter

  • java.lang.Object
    • java.util.concurrent.AbstractExecutorService
  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class ExecutorServiceAdapter
    extends java.util.concurrent.AbstractExecutorService
    Adapter that takes a Spring TaskExecutor and exposes a full java.util.concurrent.ExecutorService for it.

    This is primarily for adapting to client components that communicate via the java.util.concurrent.ExecutorService API. It can also be used as common ground between a local Spring TaskExecutor backend and a JNDI-located ManagedExecutorService in a Java EE 7 environment.

    NOTE: This ExecutorService adapter does not support the lifecycle methods in the java.util.concurrent.ExecutorService API ("shutdown()" etc), similar to a server-wide ManagedExecutorService in a Java EE 7 environment. The lifecycle is always up to the backend pool, with this adapter acting as an access-only proxy for that target pool.

    Juergen Hoeller
    See Also:
    • Constructor Summary

      Constructor and Description
      ExecutorServiceAdapter(TaskExecutor taskExecutor)
      Create a new ExecutorServiceAdapter, using the given target executor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) 
      void execute(java.lang.Runnable task) 
      boolean isShutdown() 
      boolean isTerminated() 
      void shutdown() 
      java.util.List<java.lang.Runnable> shutdownNow() 
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExecutorServiceAdapter

        public ExecutorServiceAdapter(TaskExecutor taskExecutor)
        Create a new ExecutorServiceAdapter, using the given target executor.
        taskExecutor - the target executor to delegate to
    • Method Detail

      • execute

        public void execute(java.lang.Runnable task)
      • shutdown

        public void shutdown()
      • shutdownNow

        public java.util.List<java.lang.Runnable> shutdownNow()
      • awaitTermination

        public boolean awaitTermination(long timeout,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
      • isShutdown

        public boolean isShutdown()
      • isTerminated

        public boolean isTerminated()