1 /*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15 package net.sourceforge.basher;
16
17 import java.util.List;
18 import java.util.Set;
19 import java.util.UUID;
20
21 import net.sourceforge.basher.impl.TaskContribution;
22
23 /**
24 * Defines operations for interacting with the task manager.
25 *
26 * @author Johan Lindquist
27 * @version 1.0
28 */
29 public interface TaskManager
30 {
31 /** Adds a task to the system in the form of task contribution.
32 *
33 * @param taskContribution The task contribution to add
34 */
35 public void addTask(final TaskContribution taskContribution);
36
37 /**
38 * Adds a task class to the task manager. The class does not necessarily have to implement <code>Task<code> to the
39 * task manager but <strong>must</strong> provide an empty constructor (but not necessarily public).
40 *
41 * @param taskClass The task class to add. This class must <strong>either<strong> be annotated <strong>or</strong>
42 * expose a public method named <code>executeTask</code> which will be used for task execution.
43 * If not annotated, the class <strong>may</strong> also expose any of the methods defined in <code>Task</code> to
44 * control the settings used during invocation.
45 * @param followers Followers which will be added to the task instance.
46 * @return The task created from adding the specified task instance
47 * @since 1.3
48 */
49 public TaskContribution addTask( Class taskClass, TaskContribution... followers );
50
51 /**
52 * Adds a task instance. The instance does not necessarily have to implement <code>Task<code> to the
53 * task manager.
54 *
55 * @param taskInstance The task instance to add. The instance must <strong>either<strong> be annotated <strong>or</strong>
56 * expose a public method named <code>executeTask</code> which will be used for task execution
57 * @param followers Followers which will be added to the task instance.
58 * @return The task created from adding the specified task instance
59 * @since 1.3
60 */
61 public TaskContribution addTask( Object taskInstance, TaskContribution... followers );
62
63 /**
64 * Retrieves all active tasks with the task manager.
65 *
66 * @return A list of <code>Task</code> instances.
67 */
68 public Set<TaskContribution> getTasks();
69
70 /**
71 * Retrieves the task identified by the specified name. This will search both active and removed task lists.
72 *
73 * @param name The name of the task to retrieve.
74 * @return The specified task or null if it can not be found
75 */
76 public TaskContribution getTaskByName( String name );
77
78 /**
79 * Retrives the count of the currently registered tasks.
80 *
81 * @return The number of tasks currently registered.
82 */
83 public int getNumberOfTasks();
84
85 /**
86 * Retrieves the next task available.
87 *
88 * @return A task instance or null of no tasks are available
89 */
90 public TaskExecutionContext getNextTaskExecutionContext();
91
92 /**
93 * Removes the specified task execution context from the list of active tasks.
94 *
95 * @param identifier The identifier of the task execution context to remove
96 */
97 public void removeTaskExecutionContext( UUID identifier );
98
99 }