1 /* Functions related to the java process instances. */
3 /* Copyright (c) 2007-2015. The SimGrid Team.
4 * All rights 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. */
10 #define MSG_JPROCESS_H
13 #include <simgrid/msg.h>
14 #include <simgrid/simix.h>
19 extern jfieldID jprocess_field_Process_bind;
20 extern jfieldID jprocess_field_Process_host;
21 extern jfieldID jprocess_field_Process_killTime;
22 extern jfieldID jprocess_field_Process_id;
23 extern jfieldID jprocess_field_Process_name;
24 extern jfieldID jprocess_field_Process_pid;
25 extern jfieldID jprocess_field_Process_ppid;
27 JNIEXPORT void JNICALL
28 Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
31 jobject native_to_java_process(msg_process_t process);
34 * This function returns a global reference to the java process instance
35 * specified by the parameter jprocess.
37 * @param jprocess The original java process instance.
38 * @param env The env of the current thread
40 * @return The global reference to the original java process
43 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
46 * This function delete a global reference to a java process instance.
47 * If the java process is alive the function joins it and stops it before.
49 * @param The global refernce to delete.
50 * @param env The env of the current thread
52 * @see jprocess_join()
53 * @see jprocess_exit()
55 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
59 * This function waits for a java process to terminate.
61 * @param jprocess The java process ot wait for.
62 * @param env The env of the current thread
64 * @exception If the class Process is not found the function throws
65 * the ClassNotFoundException. If the methos join() of
66 * this class is not found the function throws the exception
67 * NotSuchMethodException.
70 void jprocess_join(jobject jprocess, JNIEnv * env);
72 * This function associated a native process to a java process instance.
74 * @param jprocess The java process instance.
75 * @param process The native process to bind.
76 * @param env The env of the current thread
78 * @exception If the class Process is not found the function throws
79 * the ClassNotFoundException. If the field bind of
80 * this class is not found the function throws the exception
81 * NotSuchFieldException.
83 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
86 * This function returns a native process from a java process instance.
88 * @param jprocess The java process object from which get the native process.
89 * @param env The env of the current thread
91 * @return The function returns the native process associated to the
92 * java process object.
94 * @exception If the class Process is not found the function throws
95 * the ClassNotFoundException. If the field bind of
96 * this class is not found the function throws the exception
97 * NotSuchFieldException.
99 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
102 * This function gets the id of the specified java process.
104 * @param jprocess The java process to get the id.
105 * @param env The env of the current thread
107 * @exception If the class Process is not found the function throws
108 * the ClassNotFoundException. If the field id of
109 * this class is not found the function throws the exception
110 * NotSuchFieldException.
112 * @return The id of the specified java process.
114 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
117 * This function tests if a java process instance is valid.
118 * A java process object is valid if it is bind to a native
121 * @param jprocess The java process to test the validity.
122 * @param env The env of the current thread
124 * @return If the java process is valid the function returns true.
125 * Otherwise the function returns false.
127 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
130 * This function gets the name of the specified java process.
132 * @param jprocess The java process to get the name.
133 * @param env The env of the current thread
135 * @exception If the class Process is not found the function throws
136 * the ClassNotFoundException. If the field name of
137 * this class is not found the function throws the exception
138 * NotSuchFieldException.
140 * @return The name of the specified java process.
142 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
145 * Class org_simgrid_msg_Process
149 JNIEXPORT void JNICALL
150 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
153 * Class org_simgrid_msg_Process
155 * Signature (Lorg/simgrid/msg/Host;)V
157 JNIEXPORT void JNICALL
158 Java_org_simgrid_msg_Process_create(JNIEnv * env,
159 jobject jprocess_arg,
163 * Class org_simgrid_msg_Process
167 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
168 (JNIEnv *, jclass, jint);
171 * Class org_simgrid_msg_Process
173 * Signature (I)Lorg/simgrid/msg/Process;
175 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
176 (JNIEnv *, jclass, jint);
178 * Class org_simgrid_msg_Process
182 JNIEXPORT jobject JNICALL
183 Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
185 * Class org_simgrid_msg_Process
186 * Method currentProcess
187 * Signature ()Lorg/simgrid/msg/Process;
189 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess
192 * Class org_simgrid_msg_Process
194 * Signature (Lorg/simgrid/msg/Process;)V
196 JNIEXPORT void JNICALL
197 Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
200 * Class org_simgrid_msg_Process
202 * Signature (Lorg/simgrid/msg/Process;)V
204 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume
207 * Class org_simgrid_msg_Process
208 * Method setAutoRestart
209 * Signature (Lorg/simgrid/msg/Process;Z)V
211 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart
212 (JNIEnv *, jobject, jboolean);
214 * Class org_simgrid_msg_Process
216 * Signature (Lorg/simgrid/msg/Process;)V
218 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
222 * Class org_simgrid_msg_Process
224 * Signature (Lorg/simgrid/msg/Process;)Z
226 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
229 * Class org_simgrid_msg_Process
233 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
234 (JNIEnv *, jclass, jlong, jint);
237 * Class org_simgrid_msg_Process
241 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
242 (JNIEnv *, jobject, jdouble);
244 * Class org_simgrid_msg_Process
246 * Signature (Lorg/simgrid/msg/Process;)V
248 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
252 * Class org_simgrid_msg_Process
254 * Signature (Lorg/simgrid/msg/Host;)V
256 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
257 (JNIEnv *, jobject, jobject);
259 * Class org_simgrid_msg_Process
263 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
264 (JNIEnv *, jobject, jdouble);
266 JNIEXPORT jint JNICALL
267 Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
271 #endif /* !MSG_JPROCESS_H */