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 Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
29 jobject native_to_java_process(msg_process_t process);
32 * This function returns a global reference to the java process instance specified by the parameter jprocess.
34 * @param jprocess The original java process instance.
35 * @param env The env of the current thread
37 * @return The global reference to the original java process instance.
39 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
42 * This function delete a global reference to a java process instance.
43 * If the java process is alive the function joins it and stops it before.
45 * @param jprocess The global refernce to delete.
46 * @param env The env of the current thread
48 * @see jprocess_join()
49 * @see jprocess_exit()
51 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
54 * This function waits for a java process to terminate.
56 * @param jprocess The java process ot wait for.
57 * @param env The env of the current thread
59 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the method
60 join() of this class is not found the function throws the exception NotSuchMethodException.
62 void jprocess_join(jobject jprocess, JNIEnv * env);
65 * This function associated a native process to a java process instance.
67 * @param jprocess The java process instance.
68 * @param process The native process to bind.
69 * @param env The env of the current thread
71 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field
72 * bind of this class is not found the function throws the exception NotSuchFieldException.
74 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
77 * This function returns a native process from a java process instance.
79 * @param jprocess The java process object from which get the native process.
80 * @param env The env of the current thread
82 * @return The function returns the native process associated to the java process object.
84 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field
85 * bind of this class is not found the function throws the exception NotSuchFieldException.
87 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
90 * This function gets the id of the specified java process.
92 * @param jprocess The java process to get the id.
93 * @param env The env of the current thread
95 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field id
96 * of this class is not found the function throws the exception NotSuchFieldException.
98 * @return The id of the specified java process.
100 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
103 * This function tests if a java process instance is valid.
104 * A java process object is valid if it is bind to a native process.
106 * @param jprocess The java process to test the validity.
107 * @param env The env of the current thread
109 * @return If the java process is valid the function returns true. Otherwise the function returns false.
111 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
114 * This function gets the name of the specified java process.
116 * @param jprocess The java process to get the name.
117 * @param env The env of the current thread
119 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field name
120 * of this class is not found the function throws the exception NotSuchFieldException.
122 * @return The name of the specified java process.
124 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
127 * Class org_simgrid_msg_Process
131 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
134 * Class org_simgrid_msg_Process
136 * Signature (Lorg/simgrid/msg/Host;)V
138 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jprocess_arg, jobject jhostname);
141 * Class org_simgrid_msg_Process
145 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll (JNIEnv *, jclass, jint);
148 * Class org_simgrid_msg_Process
150 * Signature (I)Lorg/simgrid/msg/Process;
152 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID (JNIEnv *, jclass, jint);
155 * Class org_simgrid_msg_Process
159 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
162 * Class org_simgrid_msg_Process
163 * Method currentProcess
164 * Signature ()Lorg/simgrid/msg/Process;
166 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess (JNIEnv *, jclass);
169 * Class org_simgrid_msg_Process
171 * Signature (Lorg/simgrid/msg/Process;)V
173 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess);
176 * Class org_simgrid_msg_Process
178 * Signature (Lorg/simgrid/msg/Process;)V
180 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume (JNIEnv *, jobject);
183 * Class org_simgrid_msg_Process
184 * Method setAutoRestart
185 * Signature (Lorg/simgrid/msg/Process;Z)V
187 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *, jobject, jboolean);
190 * Class org_simgrid_msg_Process
192 * Signature (Lorg/simgrid/msg/Process;)V
194 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *, jobject);
197 * Class org_simgrid_msg_Process
199 * Signature (Lorg/simgrid/msg/Process;)Z
201 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended (JNIEnv *, jobject);
204 * Class org_simgrid_msg_Process
208 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep (JNIEnv *, jclass, jlong, jint);
211 * Class org_simgrid_msg_Process
215 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor (JNIEnv *, jobject, jdouble);
218 * Class org_simgrid_msg_Process
220 * Signature (Lorg/simgrid/msg/Process;)V
222 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill (JNIEnv *, jobject);
225 * Class org_simgrid_msg_Process
227 * Signature (Lorg/simgrid/msg/Host;)V
229 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate (JNIEnv *, jobject, jobject);
232 * Class org_simgrid_msg_Process
236 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *, jobject, jdouble);
238 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
241 #endif /* !MSG_JPROCESS_H */