Class SpringAsyncExecutor

All Implemented Interfaces:
AsyncExecutor

public class SpringAsyncExecutor extends DefaultAsyncJobExecutor

This is a spring based implementation of the Job Executor using spring abstraction TaskExecutor for performing background task execution.

The idea behind this implementation is to externalize the configuration of the task executor, so it can leverage to Application servers controller thread pools, for example using the commonj API. The use of unmanaged thread in application servers is discouraged by the Java EE spec.

  • Field Details

    • taskExecutor

      protected org.springframework.core.task.TaskExecutor taskExecutor
    • rejectedJobsHandler

      protected SpringRejectedJobsHandler rejectedJobsHandler
  • Constructor Details

    • SpringAsyncExecutor

      public SpringAsyncExecutor()
    • SpringAsyncExecutor

      public SpringAsyncExecutor(org.springframework.core.task.TaskExecutor taskExecutor, SpringRejectedJobsHandler rejectedJobsHandler)
  • Method Details

    • getTaskExecutor

      public org.springframework.core.task.TaskExecutor getTaskExecutor()
    • setTaskExecutor

      public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
      Required spring injected TaskExecutor implementation that will be used to execute runnable jobs.
      Parameters:
      taskExecutor -
    • getRejectedJobsHandler

      public SpringRejectedJobsHandler getRejectedJobsHandler()
    • setRejectedJobsHandler

      public void setRejectedJobsHandler(SpringRejectedJobsHandler rejectedJobsHandler)
      Required spring injected SpringRejectedJobsHandler implementation that will be used when jobs were rejected by the task executor.
      Parameters:
      rejectedJobsHandler -
    • executeAsyncJob

      public boolean executeAsyncJob(Job job)
      Specified by:
      executeAsyncJob in interface AsyncExecutor
      Overrides:
      executeAsyncJob in class DefaultAsyncJobExecutor
    • initAsyncJobExecutionThreadPool

      protected void initAsyncJobExecutionThreadPool()
      Overrides:
      initAsyncJobExecutionThreadPool in class DefaultAsyncJobExecutor