-
Notifications
You must be signed in to change notification settings - Fork 558
/
Copy pathTaskManagerService.java
74 lines (66 loc) · 2.59 KB
/
TaskManagerService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package org.menacheri.jetserver.service;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.menacheri.jetserver.app.Task;
/**
* Defines and interface for management of tasks in the server. It declares
* functionality for executing recurring tasks with delay etc. The interface may
* also be used as a repository of tasks, with features like persistence built
* in by the implementation.
*
* @author Abraham Menacherry
*
*/
public interface TaskManagerService
{
public void execute(Task task);
/**
* Creates and executes a one-shot action that becomes enabled after the given delay.
* @param task The task to be scheduled.
* @param delay Initial delay before the task is executed
* @param unit seconds, milliseconds etc for delay
* @return A scheduled future, which is a handle to the task and can be used
* to cancel it, get completed status etc.
*/
@SuppressWarnings("rawtypes")
public ScheduledFuture schedule(Task task, long delay, TimeUnit unit);
/**
* Creates and executes a periodic action that becomes enabled first after
* the given initial delay, and subsequently with the given period; that is
* executions will commence after initialDelay then initialDelay+period,
* then initialDelay + 2 * period, and so on.
*
* @param task
* The task to be scheduled.
* @param initialDelay
* Initial delay before the task is first done.
* @param period
* Fixed period of execution.
* @param unit
* seconds, milliseconds etc for delay.
* @return A scheduled future, which is a handle to the task and can be used
* to cancel it, get completed status etc.
*/
@SuppressWarnings("rawtypes")
public ScheduledFuture scheduleAtFixedRate(Task task, long initialDelay,
long period, TimeUnit unit);
/**
* Creates and executes a periodic action that becomes enabled first after
* the given initial delay, and subsequently with the given delay between
* the termination of one execution and the commencement of the next.
*
* @param task
* The task to be scheduled.
* @param initialDelay
* Initial delay before the task is first done.
* @param delay
* The delay between each subsequent execution
* @param unit
* seconds, milliseconds etc for delay.
* @return A scheduled future, which is a handle to the task and can be used
* to cancel it, get completed status etc.
*/
@SuppressWarnings("rawtypes")
public ScheduledFuture scheduleWithFixedDelay(Task task,
long initialDelay, long delay, TimeUnit unit);
}