1 /* Functions related to the java process instances. */
3 /* Copyright (c) 2007, 2009, 2010. 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
14 #include <simgrid/simix.h>
17 jfieldID jprocess_field_Process_bind;
18 jfieldID jprocess_field_Process_host;
19 jfieldID jprocess_field_Process_killTime;
20 jfieldID jprocess_field_Process_id;
21 jfieldID jprocess_field_Process_name;
22 jfieldID jprocess_field_Process_pid;
23 jfieldID jprocess_field_Process_ppid;
26 jobject native_to_java_process(m_process_t process);
29 * This function returns a global reference to the java process instance
30 * specified by the parameter jprocess.
32 * @param jprocess The original java process instance.
33 * @param env The env of the current thread
35 * @return The global reference to the original java process
38 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
41 * This function delete a global reference to a java process instance.
42 * If the java process is alive the function joins it and stops it before.
44 * @param The global refernce to delete.
45 * @param env The env of the current thread
47 * @see jprocess_join()
48 * @see jprocess_exit()
50 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
60 * the ClassNotFoundException. If the methos join() of
61 * this class is not found the function throws the exception
62 * NotSuchMethodException.
65 void jprocess_join(jobject jprocess, JNIEnv * env);
67 * This function associated a native process to a java process instance.
69 * @param jprocess The java process instance.
70 * @param process The native process to bind.
71 * @param env The env of the current thread
73 * @exception If the class Process is not found the function throws
74 * the ClassNotFoundException. If the field bind of
75 * this class is not found the function throws the exception
76 * NotSuchFieldException.
78 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
81 * This function returns a native process from a java process instance.
83 * @param jprocess The java process object from which get the native process.
84 * @param env The env of the current thread
86 * @return The function returns the native process associated to the
87 * java process object.
89 * @exception If the class Process is not found the function throws
90 * the ClassNotFoundException. If the field bind of
91 * this class is not found the function throws the exception
92 * NotSuchFieldException.
94 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
97 * This function gets the id of the specified java process.
99 * @param jprocess The java process to get the id.
100 * @param env The env of the current thread
102 * @exception If the class Process is not found the function throws
103 * the ClassNotFoundException. If the field id of
104 * this class is not found the function throws the exception
105 * NotSuchFieldException.
107 * @return The id of the specified java process.
109 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
112 * This function tests if a java process instance is valid.
113 * A java process object is valid if it is bind to a native
116 * @param jprocess The java process to test the validity.
117 * @param env The env of the current thread
119 * @return If the java process is valid the function returns true.
120 * Otherwise the function returns false.
122 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
125 * This function gets the name of the specified java process.
127 * @param jprocess The java process to get the name.
128 * @param env The env of the current thread
130 * @exception If the class Process is not found the function throws
131 * the ClassNotFoundException. If the field name of
132 * this class is not found the function throws the exception
133 * NotSuchFieldException.
135 * @return The name of the specified java process.
137 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
140 * Class org_simgrid_msg_Process
144 JNIEXPORT void JNICALL
145 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
148 * Class org_simgrid_msg_Process
150 * Signature (Lorg/simgrid/msg/Host;)V
152 JNIEXPORT void JNICALL
153 Java_org_simgrid_msg_Process_create(JNIEnv * env,
154 jobject jprocess_arg,
158 * Class org_simgrid_msg_Process
162 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
163 (JNIEnv *, jclass, jint);
166 * Class org_simgrid_msg_Process
168 * Signature (I)Lorg/simgrid/msg/Process;
170 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
171 (JNIEnv *, jclass, jint);
174 * Class org_simgrid_msg_Process
175 * Method currentProcess
176 * Signature ()Lorg/simgrid/msg/Process;
178 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
181 * Class org_simgrid_msg_Process
183 * Signature (Lorg/simgrid/msg/Process;)V
185 JNIEXPORT void JNICALL
186 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
189 * Class org_simgrid_msg_Process
191 * Signature (Lorg/simgrid/msg/Process;)V
193 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
196 * Class org_simgrid_msg_Process
198 * Signature (Lorg/simgrid/msg/Process;)Z
200 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
203 * Class org_simgrid_msg_Process
207 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
208 (JNIEnv *, jclass, jlong, jint);
211 * Class org_simgrid_msg_Process
215 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
216 (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
226 * Class org_simgrid_msg_Process
228 * Signature (Lorg/simgrid/msg/Host;)V
230 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
231 (JNIEnv *, jobject, jobject);
233 * Class org_simgrid_msg_Process
237 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
238 (JNIEnv *, jobject, jdouble);
240 #endif /* !MSG_JPROCESS_H */