org.springframework.scheduling.commonj

## Class WorkManagerTaskExecutor

- java.lang.Object
- - org.springframework.jndi.JndiAccessor
  - - org.springframework.jndi.JndiLocatorSupport
    - - org.springframework.scheduling.commonj.WorkManagerTaskExecutor

- All Implemented Interfaces:
    WorkManager, Executor, InitializingBean, AsyncListenableTaskExecutor, AsyncTaskExecutor, TaskExecutor, SchedulingTaskExecutor

  Deprecated.
  as of 5.1, in favor of the EE 7/8 based `DefaultManagedTaskExecutor`

      @Deprecated
      public class WorkManagerTaskExecutor
      extends JndiLocatorSupport
      implements AsyncListenableTaskExecutor, SchedulingTaskExecutor, WorkManager, InitializingBean

  TaskExecutor implementation that delegates to a CommonJ WorkManager, implementing the `WorkManager` interface, which either needs to be specified as reference or through the JNDI name.

  This is the central convenience class for setting up a CommonJ WorkManager in a Spring context.

  Also implements the CommonJ WorkManager interface itself, delegating all calls to the target WorkManager. Hence, a caller can choose whether it wants to talk to this executor through the Spring TaskExecutor interface or the CommonJ WorkManager interface.

  The CommonJ WorkManager will usually be retrieved from the application server's JNDI environment, as defined in the server's management console.

  Note: On EE 7/8 compliant versions of WebLogic and WebSphere, a `DefaultManagedTaskExecutor` should be preferred, following JSR-236 support in Java EE 7/8.

  Since:
    2.0
  Author:
    Juergen Hoeller

- - ### Field Summary

    - ### Fields inherited from class org.springframework.jndi.JndiLocatorSupport

      `CONTAINER_PREFIX`

    - ### Fields inherited from class org.springframework.jndi.JndiAccessor

      `logger`

    - ### Fields inherited from interface org.springframework.core.task.AsyncTaskExecutor

      `TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE`

    - ### Fields inherited from interface commonj.work.WorkManager

      `IMMEDIATE, INDEFINITE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WorkManagerTaskExecutor()` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Deprecated. Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.
    `void` | `execute(Runnable task)` Deprecated. Execute the given `task`.
    `void` | `execute(Runnable task, long startTimeout)` Deprecated.
    `WorkItem` | `schedule(Work work)` Deprecated.
    `WorkItem` | `schedule(Work work, WorkListener workListener)` Deprecated.
    `void` | `setTaskDecorator(TaskDecorator taskDecorator)` Deprecated. Specify a custom `TaskDecorator` to be applied to any `Runnable` about to be executed.
    `void` | `setWorkListener(WorkListener workListener)` Deprecated. Specify a CommonJ WorkListener to apply, if any.
    `void` | `setWorkManager(WorkManager workManager)` Deprecated. Specify the CommonJ WorkManager to delegate to.
    `void` | `setWorkManagerName(String workManagerName)` Deprecated. Set the JNDI name of the CommonJ WorkManager.
    `<T> Future<T>` | `submit(Callable<T> task)` Deprecated. Submit a Callable task for execution, receiving a Future representing that task.
    `Future<?>` | `submit(Runnable task)` Deprecated. Submit a Runnable task for execution, receiving a Future representing that task.
    `<T> ListenableFuture<T>` | `submitListenable(Callable<T> task)` Deprecated. Submit a `Callable` task for execution, receiving a `ListenableFuture` representing that task.
    `ListenableFuture<?>` | `submitListenable(Runnable task)` Deprecated. Submit a `Runnable` task for execution, receiving a `ListenableFuture` representing that task.
    `boolean` | `waitForAll(Collection workItems, long timeout)` Deprecated.
    `Collection` | `waitForAny(Collection workItems, long timeout)` Deprecated.

    - ### Methods inherited from class org.springframework.jndi.JndiLocatorSupport

      `convertJndiName, isResourceRef, lookup, lookup, setResourceRef`

    - ### Methods inherited from class org.springframework.jndi.JndiAccessor

      `getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.scheduling.SchedulingTaskExecutor

      `prefersShortLivedTasks`

- - ### Constructor Detail

    - #### WorkManagerTaskExecutor

          public WorkManagerTaskExecutor()

      Deprecated.

  - ### Method Detail

    - #### setWorkManager

          public void setWorkManager(WorkManager workManager)

      Deprecated.
      Specify the CommonJ WorkManager to delegate to.

      Alternatively, you can also specify the JNDI name of the target WorkManager.

      See Also:
        `setWorkManagerName(java.lang.String)`

    - #### setWorkManagerName

          public void setWorkManagerName(String workManagerName)

      Deprecated.
      Set the JNDI name of the CommonJ WorkManager.

      This can either be a fully qualified JNDI name, or the JNDI name relative to the current environment naming context if "resourceRef" is set to "true".

      See Also:
        `setWorkManager(commonj.work.WorkManager)`, `JndiLocatorSupport.setResourceRef(boolean)`

    - #### setWorkListener

          public void setWorkListener(WorkListener workListener)

      Deprecated.
      Specify a CommonJ WorkListener to apply, if any.

      This shared WorkListener instance will be passed on to the WorkManager by all `execute(java.lang.Runnable)` calls on this TaskExecutor.

    - #### setTaskDecorator

          public void setTaskDecorator(TaskDecorator taskDecorator)

      Deprecated.
      Specify a custom `TaskDecorator` to be applied to any `Runnable` about to be executed.

      Note that such a decorator is not necessarily being applied to the user-supplied `Runnable`/`Callable` but rather to the actual execution callback (which may be a wrapper around the user-supplied task).

      The primary use case is to set some execution context around the task's invocation, or to provide some monitoring/statistics for task execution.

      NOTE: Exception handling in `TaskDecorator` implementations is limited to plain `Runnable` execution via `execute` calls. In case of `#submit` calls, the exposed `Runnable` will be a `FutureTask` which does not propagate any exceptions; you might have to cast it and call `Future#get` to evaluate exceptions.

      Since:
        4.3

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws NamingException

      Deprecated.
      Description copied from interface: `InitializingBean`
      Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.

      This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Throws:
        `NamingException`

    - #### execute

          public void execute(Runnable task)

      Deprecated.
      Description copied from interface: `TaskExecutor`
      Execute the given `task`.

      The call might return immediately if the implementation uses an asynchronous execution strategy, or might block in the case of synchronous execution.

      Specified by:
        `execute` in interface `Executor`
      Specified by:
        `execute` in interface `TaskExecutor`
      Parameters:
        `task` - the `Runnable` to execute (never `null`)

    - #### execute

          @Deprecated
          public void execute(Runnable task,
                                          long startTimeout)

      Deprecated.
      Description copied from interface: `AsyncTaskExecutor`
      Execute the given `task`.
      Specified by:
        `execute` in interface `AsyncTaskExecutor`
      Parameters:
        `task` - the `Runnable` to execute (never `null`)
        `startTimeout` - the time duration (milliseconds) within which the task is supposed to start. This is intended as a hint to the executor, allowing for preferred handling of immediate tasks. Typical values are `AsyncTaskExecutor.TIMEOUT_IMMEDIATE` or `AsyncTaskExecutor.TIMEOUT_INDEFINITE` (the default as used by `TaskExecutor.execute(Runnable)`).
      See Also:
        `TaskExecutor.execute(Runnable)`

    - #### submit

          public Future<?> submit(Runnable task)

      Deprecated.
      Description copied from interface: `AsyncTaskExecutor`
      Submit a Runnable task for execution, receiving a Future representing that task. The Future will return a `null` result upon completion.
      Specified by:
        `submit` in interface `AsyncTaskExecutor`
      Parameters:
        `task` - the `Runnable` to execute (never `null`)
      Returns:
        a Future representing pending completion of the task

    - #### submit

          public <T> Future<T> submit(Callable<T> task)

      Deprecated.
      Description copied from interface: `AsyncTaskExecutor`
      Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.
      Specified by:
        `submit` in interface `AsyncTaskExecutor`
      Parameters:
        `task` - the `Callable` to execute (never `null`)
      Returns:
        a Future representing pending completion of the task

    - #### submitListenable

          public ListenableFuture<?> submitListenable(Runnable task)

      Deprecated.
      Description copied from interface: `AsyncListenableTaskExecutor`
      Submit a `Runnable` task for execution, receiving a `ListenableFuture` representing that task. The Future will return a `null` result upon completion.
      Specified by:
        `submitListenable` in interface `AsyncListenableTaskExecutor`
      Parameters:
        `task` - the `Runnable` to execute (never `null`)
      Returns:
        a `ListenableFuture` representing pending completion of the task

    - #### submitListenable

          public <T> ListenableFuture<T> submitListenable(Callable<T> task)

      Deprecated.
      Description copied from interface: `AsyncListenableTaskExecutor`
      Submit a `Callable` task for execution, receiving a `ListenableFuture` representing that task. The Future will return the Callable's result upon completion.
      Specified by:
        `submitListenable` in interface `AsyncListenableTaskExecutor`
      Parameters:
        `task` - the `Callable` to execute (never `null`)
      Returns:
        a `ListenableFuture` representing pending completion of the task

    - #### schedule

          public WorkItem schedule(Work work)
                            throws WorkException,
                                   IllegalArgumentException

      Deprecated.
      Specified by:
        `schedule` in interface `WorkManager`
      Throws:
        `WorkException`
        `IllegalArgumentException`

    - #### schedule

          public WorkItem schedule(Work work,
                                   WorkListener workListener)
                            throws WorkException

      Deprecated.
      Specified by:
        `schedule` in interface `WorkManager`
      Throws:
        `WorkException`

    - #### waitForAll

          public boolean waitForAll(Collection workItems,
                                    long timeout)
                             throws InterruptedException

      Deprecated.
      Specified by:
        `waitForAll` in interface `WorkManager`
      Throws:
        `InterruptedException`

    - #### waitForAny

          public Collection waitForAny(Collection workItems,
                                       long timeout)
                                throws InterruptedException

      Deprecated.
      Specified by:
        `waitForAny` in interface `WorkManager`
      Throws:
        `InterruptedException`