Search in sources :

Example 1 with WorkException

use of commonj.work.WorkException in project spring-framework by spring-projects.

the class WorkManagerTaskExecutor method execute.

//-------------------------------------------------------------------------
// Implementation of the Spring SchedulingTaskExecutor interface
//-------------------------------------------------------------------------
@Override
public void execute(Runnable task) {
    Assert.state(this.workManager != null, "No WorkManager specified");
    Work work = new DelegatingWork(this.taskDecorator != null ? this.taskDecorator.decorate(task) : task);
    try {
        if (this.workListener != null) {
            this.workManager.schedule(work, this.workListener);
        } else {
            this.workManager.schedule(work);
        }
    } catch (WorkRejectedException ex) {
        throw new TaskRejectedException("CommonJ WorkManager did not accept task: " + task, ex);
    } catch (WorkException ex) {
        throw new SchedulingException("Could not schedule task on CommonJ WorkManager", ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) WorkRejectedException(commonj.work.WorkRejectedException) WorkException(commonj.work.WorkException) Work(commonj.work.Work) SchedulingException(org.springframework.scheduling.SchedulingException)

Aggregations

Work (commonj.work.Work)1 WorkException (commonj.work.WorkException)1 WorkRejectedException (commonj.work.WorkRejectedException)1 TaskRejectedException (org.springframework.core.task.TaskRejectedException)1 SchedulingException (org.springframework.scheduling.SchedulingException)1