public class WorkManagerTaskExecutor extends JndiLocatorSupport implements AsyncListenableTaskExecutor, SchedulingTaskExecutor, WorkManager, InitializingBean
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 the upcoming EE 7 compliant versions of WebLogic and WebSphere, a
 DefaultManagedTaskExecutor
 should be preferred, following JSR-236 support in Java EE 7.
CONTAINER_PREFIXloggerTIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITEIMMEDIATE, INDEFINITE| Constructor and Description | 
|---|
| WorkManagerTaskExecutor() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | afterPropertiesSet()Invoked by a BeanFactory after it has set all bean properties supplied
 (and satisfied BeanFactoryAware and ApplicationContextAware). | 
| void | execute(Runnable task)Execute the given  task. | 
| void | execute(Runnable task,
       long startTimeout)Execute the given  task. | 
| boolean | prefersShortLivedTasks()This task executor prefers short-lived work units. | 
| WorkItem | schedule(Work work) | 
| WorkItem | schedule(Work work,
        WorkListener workListener) | 
| void | setTaskDecorator(TaskDecorator taskDecorator)Specify a custom  TaskDecoratorto be applied to anyRunnableabout to be executed. | 
| void | setWorkListener(WorkListener workListener)Specify a CommonJ WorkListener to apply, if any. | 
| void | setWorkManager(WorkManager workManager)Specify the CommonJ WorkManager to delegate to. | 
| void | setWorkManagerName(String workManagerName)Set the JNDI name of the CommonJ WorkManager. | 
| <T> Future<T> | submit(Callable<T> task)Submit a Callable task for execution, receiving a Future representing that task. | 
| Future<?> | submit(Runnable task)Submit a Runnable task for execution, receiving a Future representing that task. | 
| <T> ListenableFuture<T> | submitListenable(Callable<T> task)Submit a  Callabletask for execution, receiving aListenableFuturerepresenting that task. | 
| ListenableFuture<?> | submitListenable(Runnable task)Submit a  Runnabletask for execution, receiving aListenableFuturerepresenting that task. | 
| boolean | waitForAll(Collection workItems,
          long timeout) | 
| Collection | waitForAny(Collection workItems,
          long timeout) | 
convertJndiName, isResourceRef, lookup, lookup, setResourceRefgetJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplatepublic void setWorkManager(WorkManager workManager)
Alternatively, you can also specify the JNDI name of the target WorkManager.
setWorkManagerName(java.lang.String)public void setWorkManagerName(String workManagerName)
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".
public void setWorkListener(WorkListener workListener)
This shared WorkListener instance will be passed on to the
 WorkManager by all execute(java.lang.Runnable) calls on this TaskExecutor.
public void setTaskDecorator(TaskDecorator taskDecorator)
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.
public void afterPropertiesSet()
                        throws NamingException
InitializingBeanThis method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet in interface InitializingBeanNamingExceptionpublic void execute(Runnable task)
TaskExecutortask.
 The call might return immediately if the implementation uses an asynchronous execution strategy, or might block in the case of synchronous execution.
execute in interface Executorexecute in interface TaskExecutortask - the Runnable to execute (never null)public void execute(Runnable task, long startTimeout)
AsyncTaskExecutortask.execute in interface AsyncTaskExecutortask - 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)).public Future<?> submit(Runnable task)
AsyncTaskExecutornull result upon completion.submit in interface AsyncTaskExecutortask - the Runnable to execute (never null)public <T> Future<T> submit(Callable<T> task)
AsyncTaskExecutorsubmit in interface AsyncTaskExecutortask - the Callable to execute (never null)public ListenableFuture<?> submitListenable(Runnable task)
AsyncListenableTaskExecutorRunnable task for execution, receiving a ListenableFuture
 representing that task. The Future will return a null result upon completion.submitListenable in interface AsyncListenableTaskExecutortask - the Runnable to execute (never null)ListenableFuture representing pending completion of the taskpublic <T> ListenableFuture<T> submitListenable(Callable<T> task)
AsyncListenableTaskExecutorCallable task for execution, receiving a ListenableFuture
 representing that task. The Future will return the Callable's result upon
 completion.submitListenable in interface AsyncListenableTaskExecutortask - the Callable to execute (never null)ListenableFuture representing pending completion of the taskpublic boolean prefersShortLivedTasks()
prefersShortLivedTasks in interface SchedulingTaskExecutortrue if this TaskExecutor prefers
 short-lived taskspublic WorkItem schedule(Work work) throws WorkException, IllegalArgumentException
schedule in interface WorkManagerWorkExceptionIllegalArgumentExceptionpublic WorkItem schedule(Work work, WorkListener workListener) throws WorkException
schedule in interface WorkManagerWorkExceptionpublic boolean waitForAll(Collection workItems, long timeout) throws InterruptedException
waitForAll in interface WorkManagerInterruptedExceptionpublic Collection waitForAny(Collection workItems, long timeout) throws InterruptedException
waitForAny in interface WorkManagerInterruptedException