4 * Copyright 2006,2007 Martin Quinson, Malek Cherier All right reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package.
9 * This contains the declarations of the functions in relation with the java
13 #ifndef MSG_JPROCESS_H
14 #define MSG_JPROCESS_H
18 #include "simix/simix.h"
21 * This function returns a global reference to the java process instance
22 * specified by the parameter jprocess.
24 * @param jprocess The original java process instance.
25 * @param env The env of the current thread
27 * @return The global reference to the original java process
30 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
33 * This function delete a global reference to a java process instance.
34 * If the java process is alive the function joins it and stops it before.
36 * @param The global refernce to delete.
37 * @param env The env of the current thread
39 * @see jprocess_join()
40 * @see jprocess_exit()
42 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
46 * This function tests if the specified java process instance is alive.
47 * A java process object is alive if it has been started and has not yet
50 * @param jprocess The java process to test.
51 * @param env The env of the current thread
53 * @exception If the class Process is not found the function throws
54 * the ClassNotFoundException. If the methos isAlive() of
55 * this class is not found the function throws the exception
56 * NotSuchMethodException.
58 * @return If the java process is alive the function returns
59 * true. Otherwise the function returns false.
61 jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env);
64 * This function waits for a java process to terminate.
66 * @param jprocess The java process ot wait for.
67 * @param env The env of the current thread
69 * @exception If the class Process is not found the function throws
70 * the ClassNotFoundException. If the methos join() of
71 * this class is not found the function throws the exception
72 * NotSuchMethodException.
75 void jprocess_join(jobject jprocess, JNIEnv * env);
78 * This function starts the specified java process.
80 * @param jprocess The java process to start.
81 * @param env The env of the current thread
83 * @exception If the class Process is not found the function throws
84 * the ClassNotFoundException. If the methos start() of
85 * this class is not found the function throws the exception
86 * NotSuchMethodException.
88 void jprocess_start(jobject jprocess, JNIEnv * env);
91 * This function forces the java process to stop.
93 * @param jprocess The java process to stop.
94 * @param env The env of the current thread
96 * @exception If the class Process is not found the function throws
97 * the ClassNotFoundException. If the methos stop() of
98 * this class is not found the function throws the exception
99 * NotSuchMethodException.
101 void jprocess_exit(jobject jprocess, JNIEnv * env);
104 * This function associated a native process to a java process instance.
106 * @param jprocess The java process instance.
107 * @param process The native process to bind.
108 * @param env The env of the current thread
110 * @exception If the class Process is not found the function throws
111 * the ClassNotFoundException. If the field bind of
112 * this class is not found the function throws the exception
113 * NotSuchFieldException.
115 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
118 * This function returns a native process from a java process instance.
120 * @param jprocess The java process object from which get the native process.
121 * @param env The env of the current thread
123 * @return The function returns the native process associated to the
124 * java process object.
126 * @exception If the class Process is not found the function throws
127 * the ClassNotFoundException. If the field bind of
128 * this class is not found the function throws the exception
129 * NotSuchFieldException.
131 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
134 * This function gets the id of the specified java process.
136 * @param jprocess The java process to get the id.
137 * @param env The env of the current thread
139 * @exception If the class Process is not found the function throws
140 * the ClassNotFoundException. If the field id of
141 * this class is not found the function throws the exception
142 * NotSuchFieldException.
144 * @return The id of the specified java process.
146 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
149 * This function tests if a java process instance is valid.
150 * A java process object is valid if it is bind to a native
153 * @param jprocess The java process to test the validity.
154 * @param env The env of the current thread
156 * @return If the java process is valid the function returns true.
157 * Otherwise the function returns false.
159 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
162 * This function gets the name of the specified java process.
164 * @param jprocess The java process to get the name.
165 * @param env The env of the current thread
167 * @exception If the class Process is not found the function throws
168 * the ClassNotFoundException. If the field name of
169 * this class is not found the function throws the exception
170 * NotSuchFieldException.
172 * @return The name of the specified java process.
174 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
177 * This function yields the specified java process.
179 * @param jprocess The java process to yield.
180 * @param env The env of the current thread.
182 * @exception If the class Process is not found the function throws
183 * the ClassNotFoundException. If the method switchProcess of
184 * this class is not found the function throws the exception
185 * NotSuchMethodException.
187 void jprocess_yield(jobject jprocess, JNIEnv * env);
190 * This function locks the mutex of the specified java process.
192 * @param jprocess The java process of the mutex to lock.
193 * @param env The env of the current thread.
195 * @exception If the class Process is not found the function throws
196 * the ClassNotFoundException. If the method lockMutex of
197 * this class is not found the function throws the exception
198 * NotSuchMethodException.
200 void jprocess_lock_mutex(jobject jprocess, JNIEnv * env);
203 * This function unlocks the mutex of the specified java process.
205 * @param jprocess The java process of the mutex to unlock.
206 * @param env The env of the current thread.
208 * @exception If the class Process is not found the function throws
209 * the ClassNotFoundException. If the method unlockMutex of
210 * this class is not found the function throws the exception
211 * NotSuchMethodException.
213 void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env);
216 * This function signals the condition of the mutex of the specified java process.
218 * @param jprocess The java process of the condtion to signal.
219 * @param env The env of the current thread.
221 * @exception If the class Process is not found the function throws
222 * the ClassNotFoundException. If the method signalCond of
223 * this class is not found the function throws the exception
224 * NotSuchMethodException.
226 void jprocess_signal_cond(jobject jprocess, JNIEnv * env);
229 * This function waits the condition of the mutex of the specified java process.
231 * @param jprocess The java process of the condtion to wait for.
232 * @param env The env of the current thread.
234 * @exception If the class Process is not found the function throws
235 * the ClassNotFoundException. If the method waitCond of
236 * this class is not found the function throws the exception
237 * NotSuchMethodException.
239 void jprocess_wait_cond(jobject jprocess, JNIEnv * env);
241 void jprocess_schedule(smx_context_t context);
243 void jprocess_unschedule(smx_context_t context);
246 #endif /* !MSG_JPROCESS_H */