站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

WorkManagerTaskExecutor (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.jca.work
Class WorkManagerTaskExecutor

java.lang.Object
  extended by org.springframework.jca.work.WorkManagerTaskExecutor
All Implemented Interfaces:
WorkManager, AsyncTaskExecutor, TaskExecutor, BootstrapContextAware, SchedulingTaskExecutor

public class WorkManagerTaskExecutor
extends Object
implements SchedulingTaskExecutor, AsyncTaskExecutor, WorkManager, BootstrapContextAware

TaskExecutor implementation that delegates to a JCA 1.5 WorkManager, implementing the WorkManager interface.

This is mainly intended for use within a JCA ResourceAdapter implementation, but may also be used in a standalone environment, delegating to a locally embedded WorkManager implementation (such as Geronimo's).

Also implements the JCA 1.5 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 JCA 1.5 WorkManager interface.

Since:
2.0.3
Author:
Juergen Hoeller
See Also:
setWorkManager(javax.resource.spi.work.WorkManager), WorkManager.scheduleWork(javax.resource.spi.work.Work)

Field Summary
 
Fields inherited from interface org.springframework.core.task.AsyncTaskExecutor
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE
 
Fields inherited from interface javax.resource.spi.work.WorkManager
IMMEDIATE, INDEFINITE, UNKNOWN
 
Constructor Summary
WorkManagerTaskExecutor()
          Create a new WorkManagerTaskExecutor, expecting bean-style configuration.
WorkManagerTaskExecutor(WorkManager workManager)
          Create a new WorkManagerTaskExecutor for the given WorkManager.
 
Method Summary
 void doWork(Work work)
           
 void doWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
           
 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.
 void scheduleWork(Work work)
           
 void scheduleWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
           
 void setBlockUntilCompleted(boolean blockUntilCompleted)
          Set whether to let execute(java.lang.Runnable) block until the work has been completed.
 void setBlockUntilStarted(boolean blockUntilStarted)
          Set whether to let execute(java.lang.Runnable) block until the work has been actually started.
 void setBootstrapContext(BootstrapContext bootstrapContext)
          Specify the JCA BootstrapContext that contains the WorkManager to delegate to.
 void setWorkListener(WorkListener workListener)
          Specify a JCA 1.5 WorkListener to apply, if any.
 void setWorkManager(WorkManager workManager)
          Specify the JCA WorkManager to delegate to.
 long startWork(Work work)
           
 long startWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkManagerTaskExecutor

public WorkManagerTaskExecutor()
Create a new WorkManagerTaskExecutor, expecting bean-style configuration.

See Also:
setWorkManager(javax.resource.spi.work.WorkManager)

WorkManagerTaskExecutor

public WorkManagerTaskExecutor(WorkManager workManager)
Create a new WorkManagerTaskExecutor for the given WorkManager.

Parameters:
workManager - the JCA WorkManager to delegate to
Method Detail

setWorkManager

public void setWorkManager(WorkManager workManager)
Specify the JCA WorkManager to delegate to.


setBootstrapContext

public void setBootstrapContext(BootstrapContext bootstrapContext)
Specify the JCA BootstrapContext that contains the WorkManager to delegate to.

Specified by:
setBootstrapContext in interface BootstrapContextAware
Parameters:
bootstrapContext - BootstrapContext object to be used by this object
See Also:
InitializingBean.afterPropertiesSet(), ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)

setBlockUntilStarted

public void setBlockUntilStarted(boolean blockUntilStarted)
Set whether to let execute(java.lang.Runnable) block until the work has been actually started.

Uses the JCA startWork operation underneath, instead of the default scheduleWork.

See Also:
WorkManager.startWork(javax.resource.spi.work.Work), WorkManager.scheduleWork(javax.resource.spi.work.Work)

setBlockUntilCompleted

public void setBlockUntilCompleted(boolean blockUntilCompleted)
Set whether to let execute(java.lang.Runnable) block until the work has been completed.

Uses the JCA doWork operation underneath, instead of the default scheduleWork.

See Also:
WorkManager.doWork(javax.resource.spi.work.Work), WorkManager.scheduleWork(javax.resource.spi.work.Work)

setWorkListener

public void setWorkListener(WorkListener workListener)
Specify a JCA 1.5 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.


execute

public void execute(Runnable task)
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 TaskExecutor
Parameters:
task - the Runnable to execute (never null)

execute

public void execute(Runnable task,
                    long startTimeout)
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 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)).

prefersShortLivedTasks

public boolean prefersShortLivedTasks()
This task executor prefers short-lived work units.

Specified by:
prefersShortLivedTasks in interface SchedulingTaskExecutor
Returns:
true if this TaskExecutor prefers short-lived tasks

doWork

public void doWork(Work work)
            throws WorkException
Specified by:
doWork in interface WorkManager
Throws:
WorkException

doWork

public void doWork(Work work,
                   long delay,
                   ExecutionContext executionContext,
                   WorkListener workListener)
            throws WorkException
Specified by:
doWork in interface WorkManager
Throws:
WorkException

startWork

public long startWork(Work work)
               throws WorkException
Specified by:
startWork in interface WorkManager
Throws:
WorkException

startWork

public long startWork(Work work,
                      long delay,
                      ExecutionContext executionContext,
                      WorkListener workListener)
               throws WorkException
Specified by:
startWork in interface WorkManager
Throws:
WorkException

scheduleWork

public void scheduleWork(Work work)
                  throws WorkException
Specified by:
scheduleWork in interface WorkManager
Throws:
WorkException

scheduleWork

public void scheduleWork(Work work,
                         long delay,
                         ExecutionContext executionContext,
                         WorkListener workListener)
                  throws WorkException
Specified by:
scheduleWork in interface WorkManager
Throws:
WorkException

The Spring Framework

Copyright © 2002-2007 The Spring Framework.