DefaultManagedTaskExecutor
@Deprecated public class WorkManagerTaskExecutor extends JndiLocatorSupport implements AsyncListenableTaskExecutor, SchedulingTaskExecutor, commonj.work.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_PREFIX
logger
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE
Constructor and Description |
---|
WorkManagerTaskExecutor()
Deprecated.
|
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(java.lang.Runnable task)
Deprecated.
Execute the given
task . |
void |
execute(java.lang.Runnable task,
long startTimeout)
Deprecated.
Execute the given
task . |
commonj.work.WorkItem |
schedule(commonj.work.Work work)
Deprecated.
|
commonj.work.WorkItem |
schedule(commonj.work.Work work,
commonj.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(commonj.work.WorkListener workListener)
Deprecated.
Specify a CommonJ WorkListener to apply, if any.
|
void |
setWorkManager(commonj.work.WorkManager workManager)
Deprecated.
Specify the CommonJ WorkManager to delegate to.
|
void |
setWorkManagerName(java.lang.String workManagerName)
Deprecated.
Set the JNDI name of the CommonJ WorkManager.
|
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task)
Deprecated.
Submit a Callable task for execution, receiving a Future representing that task.
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task)
Deprecated.
Submit a Runnable task for execution, receiving a Future representing that task.
|
<T> ListenableFuture<T> |
submitListenable(java.util.concurrent.Callable<T> task)
Deprecated.
Submit a
Callable task for execution, receiving a ListenableFuture
representing that task. |
ListenableFuture<?> |
submitListenable(java.lang.Runnable task)
Deprecated.
Submit a
Runnable task for execution, receiving a ListenableFuture
representing that task. |
boolean |
waitForAll(java.util.Collection workItems,
long timeout)
Deprecated.
|
java.util.Collection |
waitForAny(java.util.Collection workItems,
long timeout)
Deprecated.
|
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
prefersShortLivedTasks
public void setWorkManager(commonj.work.WorkManager workManager)
Alternatively, you can also specify the JNDI name of the target WorkManager.
setWorkManagerName(java.lang.String)
public void setWorkManagerName(java.lang.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(commonj.work.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 javax.naming.NamingException
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean
javax.naming.NamingException
public void execute(java.lang.Runnable task)
TaskExecutor
task
.
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 java.util.concurrent.Executor
execute
in interface TaskExecutor
task
- the Runnable
to execute (never null
)public void execute(java.lang.Runnable task, long startTimeout)
AsyncTaskExecutor
task
.execute
in interface AsyncTaskExecutor
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)
).public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
AsyncTaskExecutor
null
result upon completion.submit
in interface AsyncTaskExecutor
task
- the Runnable
to execute (never null
)public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
AsyncTaskExecutor
submit
in interface AsyncTaskExecutor
task
- the Callable
to execute (never null
)public ListenableFuture<?> submitListenable(java.lang.Runnable task)
AsyncListenableTaskExecutor
Runnable
task for execution, receiving a ListenableFuture
representing that task. The Future will return a null
result upon completion.submitListenable
in interface AsyncListenableTaskExecutor
task
- the Runnable
to execute (never null
)ListenableFuture
representing pending completion of the taskpublic <T> ListenableFuture<T> submitListenable(java.util.concurrent.Callable<T> task)
AsyncListenableTaskExecutor
Callable
task for execution, receiving a ListenableFuture
representing that task. The Future will return the Callable's result upon
completion.submitListenable
in interface AsyncListenableTaskExecutor
task
- the Callable
to execute (never null
)ListenableFuture
representing pending completion of the taskpublic commonj.work.WorkItem schedule(commonj.work.Work work) throws commonj.work.WorkException, java.lang.IllegalArgumentException
schedule
in interface commonj.work.WorkManager
commonj.work.WorkException
java.lang.IllegalArgumentException
public commonj.work.WorkItem schedule(commonj.work.Work work, commonj.work.WorkListener workListener) throws commonj.work.WorkException
schedule
in interface commonj.work.WorkManager
commonj.work.WorkException
public boolean waitForAll(java.util.Collection workItems, long timeout) throws java.lang.InterruptedException
waitForAll
in interface commonj.work.WorkManager
java.lang.InterruptedException
public java.util.Collection waitForAny(java.util.Collection workItems, long timeout) throws java.lang.InterruptedException
waitForAny
in interface commonj.work.WorkManager
java.lang.InterruptedException