KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > doctaskrunner > DocumentTaskManager


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.doctaskrunner;
17
18 import org.outerj.daisy.repository.VariantKey;
19 import org.outerj.daisy.repository.RepositoryException;
20
21 /**
22  * The DocumentTaskManager is concerned with the execution of a certain task
23  * on a set of documents. The task is executed in a background-thread.
24  * The task is executed once for each document in the set,
25  * and the state of execution for each document is tracked individually. This execution
26  * progress is recorded persistently, so it is possible to see afterwards if
27  * the task has run on all documents, and what the outcome was (succesful or error),
28  * even after server restarts.
29  *
30  * <p>The run-information of a task can afterwards be explicitely deleted, or the implementation
31  * of DocumentTaskManager may provide automatic cleanup based on an expiration interval.
32  */

33 public interface DocumentTaskManager {
34     /**
35      * Runs a task.
36      *
37      * <p>The documentSelection can be created via {@link #createEnumerationDocumentSelection(org.outerj.daisy.repository.VariantKey[])}
38      * or {@link #createQueryDocumentSelection(String)}.
39      *
40      * <p>The taskSpecification can be created via {@link #createTaskSpecification(String, String, String, boolean)} or
41      * {@link #createSimpleActionsTaskSpecification(String, boolean)}.
42      *
43      * <p>Non-administrator users can only run tasks created via {@link #createSimpleActionsTaskSpecification(String, boolean)}, since
44      * using generic scripting languages nasty things can be done (infinite loops, calling System.exit, etc.).
45      *
46      * <p>After creation of the task, this method returns immediatelly. The state of the task
47      * can then be queried using the {@link #getTask(long)} method.
48      *
49      * @return the ID of the task
50      */

51     long runTask(DocumentSelection documentSelection, TaskSpecification taskSpecification) throws TaskException, RepositoryException;
52
53     Task getTask(long id) throws TaskException, RepositoryException;
54
55     /**
56      * For non-administrator users, this returns all tasks belonging to the user.
57      * For users acting in the Administrator role, this returns all tasks, of all users.
58      */

59     Tasks getTasks() throws TaskException, RepositoryException;
60
61     /**
62      * Deletes a task. A task can only be deleted if it isn't running.
63      */

64     void deleteTask(long id) throws TaskException, RepositoryException;
65
66     /**
67      * Interrupts a task (i.e. stop it after the document that's currently processed).
68      */

69     void interruptTask(long id) throws TaskException, RepositoryException;
70
71     TaskDocDetails getTaskDocDetails(long taskId) throws TaskException, RepositoryException;
72
73     TaskSpecification createTaskSpecification(String JavaDoc description, String JavaDoc script, String JavaDoc scriptLanguage, boolean stopOnFirstError);
74
75     SimpleActionsTaskSpecification createSimpleActionsTaskSpecification(String JavaDoc description, boolean stopOnFirstError);
76
77     DocumentSelection createQueryDocumentSelection(String JavaDoc query);
78
79     DocumentSelection createEnumerationDocumentSelection(VariantKey[] variantKeys);
80 }
81
Popular Tags