1 /*
2 Copyright (C) 2007 Grid Systems, S.A.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 package nextgrid.api.pom;
19
20 /**
21 * Provides control and monitoring operations for the enaction user.
22 *
23 * @author Rodrigo Ruiz
24 */
25 public interface ProcessController {
26
27 /**
28 * Workflow state.
29 */
30 public static enum State {
31 /** Default State. */
32 RUNNING,
33 /** Pause state (until resumed or cancelled). */
34 PAUSED,
35 /** Cancelled state. */
36 CANCELLED,
37 /** Finished state. */
38 FINISHED
39 }
40
41 /**
42 * Pauses a workflow execution.
43 *
44 * @throws ProcessException If an error occurs
45 * @throws InterruptedException If the thread execution is interrupted
46 */
47 void pause() throws ProcessException, InterruptedException;
48
49 /**
50 * Resumes a workflow execution.
51 *
52 * @throws ProcessException If an error occurs
53 */
54 void resume() throws ProcessException;
55
56 /**
57 * Gets the current state of the workflow execution.
58 *
59 * @return The workflow execution current state
60 */
61 State getState();
62
63 /**
64 * Starts the process enaction.
65 *
66 * @throws ProcessException If an error occurs
67 */
68 void start() throws ProcessException;
69
70 /**
71 * Cancels the process enaction.
72 *
73 * @throws ProcessException If an error occurs
74 * @throws InterruptedException If the thread execution is interrupted
75 */
76 void cancel() throws ProcessException, InterruptedException;
77
78 /**
79 * Suspends the current thread until the workflow execution finishes.
80 *
81 * @throws ProcessException If an error occurs
82 * @throws InterruptedException If the thread execution is interrupted
83 */
84 void join() throws ProcessException, InterruptedException;
85
86 /**
87 * Synchronous workflow execution.
88 *
89 * @throws ProcessException If an error occurs
90 * @throws InterruptedException If the thread execution is interrupted
91 */
92 void run() throws ProcessException, InterruptedException;
93 }