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>
16 jobject native_to_java_process(m_process_t process);
19 * This function returns a global reference to the java process instance
20 * specified by the parameter jprocess.
22 * @param jprocess The original java process instance.
23 * @param env The env of the current thread
25 * @return The global reference to the original java process
28 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
31 * This function delete a global reference to a java process instance.
32 * If the java process is alive the function joins it and stops it before.
34 * @param The global refernce to delete.
35 * @param env The env of the current thread
37 * @see jprocess_join()
38 * @see jprocess_exit()
40 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
44 * This function waits for a java process to terminate.
46 * @param jprocess The java process ot wait for.
47 * @param env The env of the current thread
49 * @exception If the class Process is not found the function throws
50 * the ClassNotFoundException. If the methos join() of
51 * this class is not found the function throws the exception
52 * NotSuchMethodException.
55 void jprocess_join(jobject jprocess, JNIEnv * env);
58 * This function starts the specified java process.
60 * @param jprocess The java process to start.
61 * @param env The env of the current thread
63 * @exception If the class Process is not found the function throws
64 * the ClassNotFoundException. If the methos start() of
65 * this class is not found the function throws the exception
66 * NotSuchMethodException.
68 void jprocess_start(jobject jprocess, JNIEnv * env);
71 * This function associated a native process to a java process instance.
73 * @param jprocess The java process instance.
74 * @param process The native process to bind.
75 * @param env The env of the current thread
77 * @exception If the class Process is not found the function throws
78 * the ClassNotFoundException. If the field bind of
79 * this class is not found the function throws the exception
80 * NotSuchFieldException.
82 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
85 * This function returns a native process from a java process instance.
87 * @param jprocess The java process object from which get the native process.
88 * @param env The env of the current thread
90 * @return The function returns the native process associated to the
91 * java process object.
93 * @exception If the class Process is not found the function throws
94 * the ClassNotFoundException. If the field bind of
95 * this class is not found the function throws the exception
96 * NotSuchFieldException.
98 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
101 * This function gets the id of the specified java process.
103 * @param jprocess The java process to get the id.
104 * @param env The env of the current thread
106 * @exception If the class Process is not found the function throws
107 * the ClassNotFoundException. If the field id of
108 * this class is not found the function throws the exception
109 * NotSuchFieldException.
111 * @return The id of the specified java process.
113 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
116 * This function tests if a java process instance is valid.
117 * A java process object is valid if it is bind to a native
120 * @param jprocess The java process to test the validity.
121 * @param env The env of the current thread
123 * @return If the java process is valid the function returns true.
124 * Otherwise the function returns false.
126 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
129 * This function gets the name of the specified java process.
131 * @param jprocess The java process to get the name.
132 * @param env The env of the current thread
134 * @exception If the class Process is not found the function throws
135 * the ClassNotFoundException. If the field name of
136 * this class is not found the function throws the exception
137 * NotSuchFieldException.
139 * @return The name of the specified java process.
141 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
144 * Class org_simgrid_msg_Process
148 JNIEXPORT void JNICALL
149 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
152 * Class org_simgrid_msg_Process
154 * Signature (Lsimgrid/msg/Host;)V
156 JNIEXPORT void JNICALL
157 Java_org_simgrid_msg_Process_create(JNIEnv * env,
158 jobject jprocess, jobject jhost);
161 * Class org_simgrid_msg_Process
165 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
166 (JNIEnv *, jclass, jint);
169 * Class org_simgrid_msg_Process
171 * Signature (I)Lsimgrid/msg/Process;
173 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
174 (JNIEnv *, jclass, jint);
177 * Class org_simgrid_msg_Process
178 * Method currentProcess
179 * Signature ()Lsimgrid/msg/Process;
181 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
184 * Class org_simgrid_msg_Process
186 * Signature (Lsimgrid/msg/Process;)V
188 JNIEXPORT void JNICALL
189 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
192 * Class org_simgrid_msg_Process
194 * Signature (Lsimgrid/msg/Process;)V
196 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
199 * Class org_simgrid_msg_Process
201 * Signature (Lsimgrid/msg/Process;)Z
203 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
206 * Class org_simgrid_msg_Process
210 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
211 (JNIEnv *, jclass, jlong, jint);
214 * Class org_simgrid_msg_Process
218 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
219 (JNIEnv *, jobject, jdouble);
221 * Class org_simgrid_msg_Process
223 * Signature (Lsimgrid/msg/Process;)V
225 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
229 * Class org_simgrid_msg_Process
231 * Signature (Lsimgrid/msg/Host;)V
233 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
234 (JNIEnv *, jobject, jobject);
235 #endif /* !MSG_JPROCESS_H */