/Users/lyon/j4p/src/javagroup/process/JProcess.java
|
1 /*
2 * Copyright (C) 1997 Luke Gorrie
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
17 * MA 02139, USA.
18 */
19
20 package javagroup.process;
21
22 import javagroup.util.Resource;
23
24 /**
25 * An interface for classes representing processes inside the JVM.
26 *
27 * @author Luke Gorrie
28 */
29 public interface JProcess {
30
31 /**
32 * State constant.
33 */
34 public static final int UNSTARTED = 0;
35 /**
36 * State constant.
37 */
38 public static final int RUNNING = 1;
39 /**
40 * State constant.
41 */
42 public static final int DEAD = 2;
43
44 /**
45 * Gets the name of this process.
46 *
47 * @return The process name.
48 */
49 public String getName();
50
51 /**
52 * Gets the unique ID number for the process.
53 *
54 * @return JProcess ID.
55 */
56 public long getPid();
57
58 /**
59 * Set the process running on its own Thread.
60 */
61 public void launch();
62
63 /**
64 * Get the state of the process.
65 *
66 * @return the state, matching one of the state constants
67 */
68 public int getState();
69
70 /**
71 * Return the ThreadGroup for this JProcess. All Threads belonging to
72 * the process must be members of this ThreadGroup, or of its children
73 *
74 * @return The process ThreadGroup.
75 */
76 public ThreadGroup getThreadGroup();
77
78 /**
79 * Return the ClassLoader that was used to load the classes for this
80 * process.
81 *
82 * @return The ClassLoader used, or null if not appropriate.
83 */
84 public ClassLoader getClassLoader();
85
86 /**
87 * Binds a given resource the the process. The process will lock the
88 * resource, and release the lock upon process death.
89 *
90 * @param resource The resource to bind to the process.
91 */
92 public void registerResource(Resource resource);
93
94 /**
95 * Binds the process to a resource. The process will lock the
96 * resource, but the process will not be garbage collected while the
97 * resource is valid, or it is explicitly killed. When the process
98 * dies, it will release it's lock on the resource.
99 *
100 * @param resource The resource to bind the process to.
101 */
102 public void registerAndBindToResource(Resource resource);
103
104 /**
105 * Wait until the process terminates.
106 */
107 public void waitFor();
108
109 /**
110 * Get the exit code of the process. This method blocks until the
111 * process is terminated. <br> <i>Not implemented</i>
112 */
113 public int getExitCode();
114
115 }
116
117