01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: Executor.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.scheduler;
09:
10: import com.uwyn.rife.scheduler.exceptions.SchedulerExecutionException;
11:
12: public abstract class Executor {
13: private Scheduler mScheduler = null;
14:
15: public Scheduler getScheduler() {
16: return mScheduler;
17: }
18:
19: final void startTaskExecution(Task task)
20: throws SchedulerExecutionException {
21: assert task != null;
22:
23: ExecutorThread executor_thread = new ExecutorThread(this , task);
24: Thread thread = new Thread(executor_thread,
25: getHandledTasktype());
26: thread.start();
27: }
28:
29: void setScheduler(Scheduler scheduler) {
30: mScheduler = scheduler;
31: }
32:
33: protected long getRescheduleDelay() {
34: return 1000;
35: }
36:
37: public abstract boolean executeTask(Task task);
38:
39: public abstract String getHandledTasktype();
40: }
|