java.lang.Object | |||
↳ | org.springframework.jndi.JndiAccessor | ||
↳ | org.springframework.jndi.JndiLocatorSupport | ||
↳ | org.springframework.scheduling.commonj.WorkManagerTaskExecutor |
TaskExecutor implementation that delegates to a CommonJ WorkManager, implementing the commonj.work.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: At the time of this writing, the CommonJ WorkManager facility is only supported on IBM WebSphere 6.0+ and BEA WebLogic 9.0+, despite being such a crucial API for an application server. (There is a similar facility available on WebSphere 5.1 Enterprise, though, which we will discuss below.)
On JBoss and GlassFish, a similar facility is available through
the JCA WorkManager. See the
JBossWorkManagerTaskExecutor
GlassFishWorkManagerTaskExecutor
classes which are the direct equivalent of this CommonJ adapter class.
A similar facility is available on WebSphere 5.1, under the name "Asynch Beans". Its central interface is called WorkManager too and is also obtained from JNDI, just like a standard CommonJ WorkManager. However, this WorkManager variant is notably different: The central execution method is called "startWork" instead of "schedule", and takes a slightly different Work interface as parameter.
Support for this WebSphere 5.1 variant can be built with this class
and its helper DelegatingWork as template: Call the WorkManager's
startWork(Work)
instead of schedule(Work)
in the execute(Runnable)
implementation. Furthermore,
for simplicity's sake, drop the entire "Implementation of the CommonJ
WorkManager interface" section (and the corresponding
implements WorkManager
clause at the class level).
Of course, you also need to change all commonj.work
imports in
your WorkManagerTaskExecutor and DelegatingWork variants to the corresponding
WebSphere API imports (com.ibm.websphere.asynchbeans.WorkManager
and com.ibm.websphere.asynchbeans.Work
, respectively).
This should be sufficient to get a TaskExecutor adapter for WebSphere 5.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jndi.JndiLocatorSupport
| |||||||||||
From interface
org.springframework.core.task.AsyncTaskExecutor
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jndi.JndiAccessor
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
| |||||||||||
Execute the given
task . | |||||||||||
Execute the given
task . | |||||||||||
This task executor prefers short-lived work units.
| |||||||||||
Specify a CommonJ WorkListener to apply, if any.
| |||||||||||
Specify the CommonJ WorkManager to delegate to.
| |||||||||||
Set the JNDI name of the CommonJ WorkManager.
| |||||||||||
Submit a Callable task for execution, receiving a Future representing that task.
| |||||||||||
Submit a Runnable task for execution, receiving a Future representing that task.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jndi.JndiLocatorSupport
| |||||||||||
From class
org.springframework.jndi.JndiAccessor
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.util.concurrent.Executor
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.core.task.AsyncTaskExecutor
| |||||||||||
From interface
org.springframework.core.task.TaskExecutor
| |||||||||||
From interface
org.springframework.scheduling.SchedulingTaskExecutor
|
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
This 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.
NamingException |
---|
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.
task | the Runnable to execute (never null ) |
---|
Execute the given task
.
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 TIMEOUT_IMMEDIATE
or TIMEOUT_INDEFINITE (the default as used by execute(Runnable) ). |
This task executor prefers short-lived work units.
true
if this TaskExecutor
prefers
short-lived tasks
IllegalArgumentException | |
---|---|
WorkException |
Specify a CommonJ WorkListener to apply, if any.
This shared WorkListener instance will be passed on to the
WorkManager by all execute(Runnable)
calls on this TaskExecutor.
Specify the CommonJ WorkManager to delegate to.
Alternatively, you can also specify the JNDI name of the target WorkManager.
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".
Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.
task | the Callable to execute (never null ) |
---|
Submit a Runnable task for execution, receiving a Future representing that task.
The Future will return a null
result upon completion.
task | the Runnable to execute (never null ) |
---|