Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
throw the right exception corresponding to TimeoutFailureException
[simgrid.git] / src / java / jmsg_application_handler.c
1 /*
2  * Copyright 2006,2007,2010 Da SimGrid Team.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package.
6  *
7  * Upcalls to the Java functions used as callback to the FleXML application file parser.
8  */
9 #include "jmsg_application_handler.h"
10
11 #include "jmsg.h"
12
13 #include "surf/surfxml_parse.h"
14 #include "jxbt_utilities.h"
15 void  japplication_handler_on_start_document(void) {
16   jclass cls;
17   JNIEnv * env = get_current_thread_env();
18   jmethodID id =
19       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
20           "onStartDocument", "()V");
21
22   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
23     return;
24
25   (*env)->CallStaticVoidMethod(env, cls, id);
26 }
27
28 void japplication_handler_on_end_document(void) {
29   jclass cls;
30   JNIEnv * env = get_current_thread_env();
31   jmethodID id =
32       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
33           "onEndDocument", "()V");
34
35   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
36     return;
37
38   (*env)->CallStaticVoidMethod(env, cls, id);
39 }
40
41 void japplication_handler_on_begin_process(void) {
42   jstring jhostName;
43   jstring jfunction;
44   jclass cls;
45   JNIEnv * env = get_current_thread_env();
46   jmethodID id =
47       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
48           "onBeginProcess",
49           "(Ljava/lang/String;Ljava/lang/String;)V");
50   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
51     return;
52   jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
53   jfunction =
54       (jstring) (*env)->NewStringUTF(env, A_surfxml_process_function);
55   (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
56 }
57
58 void japplication_handler_on_process_arg(void) {
59   jstring jarg;
60   jclass cls;
61   JNIEnv * env = get_current_thread_env();
62   jmethodID id =
63       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
64           "onProcessArg", "(Ljava/lang/String;)V");
65   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
66     return;
67   jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
68
69   (*env)->CallStaticVoidMethod(env, cls, id, jarg);
70 }
71
72 void japplication_handler_on_property(void) {
73   jstring jid;
74   jstring jvalue;
75   jclass cls;
76   JNIEnv * env = get_current_thread_env();
77   jmethodID id =
78       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
79           "onProperty",
80           "(Ljava/lang/String;Ljava/lang/String;)V");
81   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
82     return;
83
84   jid = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_id);
85   jvalue = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_value);
86   (*env)->CallStaticVoidMethod(env, cls, id, jid, jvalue);
87 }
88
89 void japplication_handler_on_end_process(void) {
90   JNIEnv * env = get_current_thread_env();
91   jclass cls;
92   jmethodID id =
93       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
94           "onEndProcess", "()V");
95   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
96     return;
97   (*env)->CallStaticVoidMethod(env, cls, id);
98 }