Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add missing files
[simgrid.git] / src / bindings / java / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007-2012. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #ifndef MSG_JPROCESS_H
10 #define MSG_JPROCESS_H
11
12 #include <jni.h>
13 #include <msg/msg.h>
14 #include <simgrid/simix.h>
15
16 //Cached java fields
17 extern jfieldID jprocess_field_Process_bind;
18 extern jfieldID jprocess_field_Process_host;
19 extern jfieldID jprocess_field_Process_killTime;
20 extern jfieldID jprocess_field_Process_id;
21 extern jfieldID jprocess_field_Process_name;
22 extern jfieldID jprocess_field_Process_pid;
23 extern jfieldID jprocess_field_Process_ppid;
24
25 JNIEXPORT void JNICALL
26 Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
27
28
29 jobject native_to_java_process(msg_process_t process);
30
31 /**
32  * This function returns a global reference to the  java process instance 
33  * specified by the parameter jprocess.
34  *
35  * @param jprocess              The original java process instance.
36  * @param env                   The env of the current thread
37  *
38  * @return                              The global reference to the original java process 
39  *                                              instance.
40  */
41 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
42
43 /**
44  * This function delete a global reference to a java process instance.
45  * If the java process is alive the function joins it and stops it before.
46  *
47  * @param                               The global refernce to delete.
48  * @param env                   The env of the current thread
49  *
50  * @see                                 jprocess_join()
51  * @see                                 jprocess_exit()
52  */
53 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
54
55
56 /**
57  * This function waits for a java process to terminate.
58  *
59  * @param jprocess              The java process ot wait for.
60  * @param env                   The env of the current thread
61  *
62  * @exception                   If the class Process is not found the function throws 
63  *                                              the ClassNotFoundException. If the methos join() of 
64  *                                              this class is not found the function throws the exception 
65  *                                              NotSuchMethodException. 
66  *
67  */
68 void jprocess_join(jobject jprocess, JNIEnv * env);
69 /**
70  * This function associated a native process to a java process instance.
71  *
72  * @param jprocess              The java process instance.
73  * @param process               The native process to bind.
74  * @param env                   The env of the current thread
75  *
76  * @exception                   If the class Process is not found the function throws 
77  *                                              the ClassNotFoundException. If the field bind of 
78  *                                              this class is not found the function throws the exception 
79  *                                              NotSuchFieldException.  
80  */
81 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
82
83 /**
84  * This function returns a native process from a java process instance.
85  *
86  * @param jprocess              The java process object from which get the native process.
87  * @param env                   The env of the current thread
88  *
89  * @return                              The function returns the native process associated to the
90  *                                              java process object.
91  *
92  * @exception                   If the class Process is not found the function throws 
93  *                                              the ClassNotFoundException. If the field bind of 
94  *                                              this class is not found the function throws the exception 
95  *                                              NotSuchFieldException.  
96  */
97 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
98
99 /**
100  * This function gets the id of the specified java process.
101  *
102  * @param jprocess              The java process to get the id.
103  * @param env                   The env of the current thread
104  *
105  * @exception                   If the class Process is not found the function throws 
106  *                                              the ClassNotFoundException. If the field id of 
107  *                                              this class is not found the function throws the exception 
108  *                                              NotSuchFieldException.  
109  *
110  * @return                              The id of the specified java process.
111  */
112 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
113
114 /**
115  * This function tests if a java process instance is valid.
116  * A java process object is valid if it is bind to a native 
117  * process.
118  *
119  * @param jprocess              The java process to test the validity.
120  * @param env                   The env of the current thread
121  *
122  * @return                              If the java process is valid the function returns true.
123  *                                              Otherwise the function returns false.
124  */
125 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
126
127 /**
128  * This function gets the name of the specified java process.
129  *
130  * @param jprocess              The java process to get the name.
131  * @param env                   The env of the current thread
132  *
133  * @exception                   If the class Process is not found the function throws 
134  *                                              the ClassNotFoundException. If the field name of 
135  *                                              this class is not found the function throws the exception 
136  *                                              NotSuchFieldException.  
137  *
138  * @return                              The name of the specified java process.
139  */
140 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
141
142 /*
143  * Class                org_simgrid_msg_Process
144  * Method               nativeInit
145  * Signature    ();
146  */
147 JNIEXPORT void JNICALL
148 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
149
150 /*
151  * Class                org_simgrid_msg_Process
152  * Method               create
153  * Signature    (Lorg/simgrid/msg/Host;)V
154  */
155 JNIEXPORT void JNICALL
156 Java_org_simgrid_msg_Process_create(JNIEnv * env,
157                                     jobject jprocess_arg,
158                                     jobject jhostname);
159
160 /*
161  * Class                org_simgrid_msg_Process
162  * Method               killAll
163  * Signature    (I)I
164  */
165 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
166     (JNIEnv *, jclass, jint);
167
168 /*
169  * Class                org_simgrid_msg_Process
170  * Method               fromPID
171  * Signature    (I)Lorg/simgrid/msg/Process;
172  */
173 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
174     (JNIEnv *, jclass, jint);
175 /*
176  * Class        org_simgrid_msg_Process
177  * Method       waitFor
178  * Signature    (D)V
179  */
180 JNIEXPORT jobject JNICALL
181 Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
182 /*
183  * Class                org_simgrid_msg_Process
184  * Method               currentProcess
185  * Signature    ()Lorg/simgrid/msg/Process;
186  */
187 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
188     (JNIEnv *, jclass);
189 /*
190  * Class                org_simgrid_msg_Process
191  * Method               suspend
192  * Signature    (Lorg/simgrid/msg/Process;)V
193  */
194 JNIEXPORT void JNICALL
195 Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
196                                           jobject jprocess);
197 /*
198  * Class                org_simgrid_msg_Process
199  * Method               resume
200  * Signature    (Lorg/simgrid/msg/Process;)V
201  */
202 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume
203     (JNIEnv *, jobject);
204 /*
205  * Class        org_simgrid_msg_Process
206  * Method       setAutoRestart
207  * Signature    (Lorg/simgrid/msg/Process;Z)V
208  */
209 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart
210     (JNIEnv *, jobject, jboolean);
211 /*
212  * Class        org_simgrid_msg_Process
213  * Method       restart
214  * Signature    (Lorg/simgrid/msg/Process;)V
215  */
216 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
217     (JNIEnv *, jobject);
218
219 /*
220  * Class                org_simgrid_msg_Process
221  * Method               isSuspended
222  * Signature    (Lorg/simgrid/msg/Process;)Z
223  */
224 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
225     (JNIEnv *, jobject);
226 /*
227  * Class                org_simgrid_msg_Process
228  * Method               sleep
229  * Signature    (DI)V
230  */
231 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
232     (JNIEnv *, jclass, jlong, jint);
233
234 /*
235  * Class                org_simgrid_msg_Process
236  * Method               waitFor
237  * Signature    (D)V
238  */
239 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
240     (JNIEnv *, jobject, jdouble);
241 /*
242  * Class                org_simgrid_msg_Process
243  * Method               kill
244  * Signature    (Lorg/simgrid/msg/Process;)V
245  */
246 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
247     (JNIEnv *, jobject);
248
249 /*
250  * Class                org_simgrid_msg_Process
251  * Method               migrate
252  * Signature    (Lorg/simgrid/msg/Host;)V
253  */
254 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
255     (JNIEnv *, jobject, jobject);
256 /*
257  * Class                org_simgrid_msg_Process
258  * Method               setKillTime
259  * Signature    (D)V
260  */
261 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
262     (JNIEnv *, jobject, jdouble);
263
264 JNIEXPORT jint JNICALL
265 Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
266
267
268 #endif                          /* !MSG_JPROCESS_H */