Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.jca.work
Class SimpleTaskWorkManager

    java.lang.Object
      org.springframework.jca.work.SimpleTaskWorkManager

All Implemented Interfaces:
  javax.resource.spi.work.WorkManager

    public class SimpleTaskWorkManager

extends java.lang.Object
implements javax.resource.spi.work.WorkManager

Simple JCA 1.5 `WorkManager` implementation that delegates to a Spring `TaskExecutor`. Provides simple task execution including start timeouts, but without support for a JCA ExecutionContext (i.e. without support for imported transactions).

Uses a `SyncTaskExecutor` for `doWork(javax.resource.spi.work.Work)` calls and a `SimpleAsyncTaskExecutor` for `startWork(javax.resource.spi.work.Work)` and `scheduleWork(javax.resource.spi.work.Work)` calls, by default. These default task executors can be overridden through configuration.

NOTE: This WorkManager does not provide thread pooling by default! Specify a `ThreadPoolTaskExecutor` (or any other thread-pooling TaskExecutor) as "asyncTaskExecutor" in order to achieve actual thread pooling.

This WorkManager automatically detects a specified `AsyncTaskExecutor` implementation and uses its extended timeout functionality where appropriate. JCA WorkListeners are fully supported in any case.

Since:
  2.0.3
Author:
  Juergen Hoeller
See Also:
  `setSyncTaskExecutor(org.springframework.core.task.TaskExecutor)`, `setAsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor)`

Field Summary

Fields inherited from interface javax.resource.spi.work.WorkManager
`IMMEDIATE, INDEFINITE, UNKNOWN`

Constructor Summary
`SimpleTaskWorkManager()`

Method Summary
`void` | `doWork(javax.resource.spi.work.Work work)`
`void` | `doWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener)`
`protected long` | `executeWork(TaskExecutor taskExecutor, javax.resource.spi.work.Work work, long startTimeout, boolean blockUntilStarted, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener)` Execute the given Work on the specified TaskExecutor.
`void` | `scheduleWork(javax.resource.spi.work.Work work)`
`void` | `scheduleWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener)`
`void` | `setAsyncTaskExecutor(AsyncTaskExecutor asyncTaskExecutor)` Specify the TaskExecutor to use for asynchronous work execution (i.e.
`void` | `setSyncTaskExecutor(TaskExecutor syncTaskExecutor)` Specify the TaskExecutor to use for synchronous work execution (i.e.
`long` | `startWork(javax.resource.spi.work.Work work)`
`long` | `startWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleTaskWorkManager

    public SimpleTaskWorkManager()

Method Detail

### setSyncTaskExecutor

    public void setSyncTaskExecutor(TaskExecutor syncTaskExecutor)

  Specify the TaskExecutor to use for synchronous work execution (i.e. `doWork(javax.resource.spi.work.Work)` calls).

  Default is a `SyncTaskExecutor`.

### setAsyncTaskExecutor

    public void setAsyncTaskExecutor(AsyncTaskExecutor asyncTaskExecutor)

  Specify the TaskExecutor to use for asynchronous work execution (i.e. `startWork(javax.resource.spi.work.Work)` and `scheduleWork(javax.resource.spi.work.Work)` calls).

  This will typically (but not necessarily) be an `AsyncTaskExecutor` implementation. Default is a `SimpleAsyncTaskExecutor`.

### doWork

    public void doWork(javax.resource.spi.work.Work work)
                throws javax.resource.spi.work.WorkException

  Specified by:
    `doWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### doWork

    public void doWork(javax.resource.spi.work.Work work,
                       long startTimeout,
                       javax.resource.spi.work.ExecutionContext executionContext,
                       javax.resource.spi.work.WorkListener workListener)
                throws javax.resource.spi.work.WorkException

  Specified by:
    `doWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### startWork

    public long startWork(javax.resource.spi.work.Work work)
                   throws javax.resource.spi.work.WorkException

  Specified by:
    `startWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### startWork

    public long startWork(javax.resource.spi.work.Work work,
                          long startTimeout,
                          javax.resource.spi.work.ExecutionContext executionContext,
                          javax.resource.spi.work.WorkListener workListener)
                   throws javax.resource.spi.work.WorkException

  Specified by:
    `startWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### scheduleWork

    public void scheduleWork(javax.resource.spi.work.Work work)
                      throws javax.resource.spi.work.WorkException

  Specified by:
    `scheduleWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### scheduleWork

    public void scheduleWork(javax.resource.spi.work.Work work,
                             long startTimeout,
                             javax.resource.spi.work.ExecutionContext executionContext,
                             javax.resource.spi.work.WorkListener workListener)
                      throws javax.resource.spi.work.WorkException

  Specified by:
    `scheduleWork` in interface `javax.resource.spi.work.WorkManager`
  Throws:
    `javax.resource.spi.work.WorkException`

### executeWork

    protected long executeWork(TaskExecutor taskExecutor,
                               javax.resource.spi.work.Work work,
                               long startTimeout,
                               boolean blockUntilStarted,
                               javax.resource.spi.work.ExecutionContext executionContext,
                               javax.resource.spi.work.WorkListener workListener)
                        throws javax.resource.spi.work.WorkException

  Execute the given Work on the specified TaskExecutor.

  Parameters:
    `taskExecutor` - the TaskExecutor to use
    `work` - the Work to execute
    `startTimeout` - the time duration within which the Work is supposed to start
    `blockUntilStarted` - whether to block until the Work has started
    `executionContext` - the JCA ExecutionContext for the given Work
    `workListener` - the WorkListener to clal for the given Work
  Returns:
    the time elapsed from Work acceptance until start of execution (or -1 if not applicable or not known)
  Throws:
    `javax.resource.spi.work.WorkException` - if the TaskExecutor did not accept the Work

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD