Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update documentation
[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
10 #include "jmsg_application_handler.h"
11
12 #include "jmsg.h"
13
14 #include "surf/surfxml_parse.h"
15 #include "jxbt_utilities.h"
16 void  japplication_handler_on_start_document(void) {
17   jclass cls;
18   JNIEnv * env = get_current_thread_env();
19   jmethodID id =
20       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
21           "onStartDocument", "()V");
22
23   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
24     return;
25
26   (*env)->CallStaticVoidMethod(env, cls, id);
27 }
28
29 void japplication_handler_on_end_document(void) {
30   jclass cls;
31   JNIEnv * env = get_current_thread_env();
32   jmethodID id =
33       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
34           "onEndDocument", "()V");
35
36   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
37     return;
38
39   (*env)->CallStaticVoidMethod(env, cls, id);
40 }
41
42 void japplication_handler_on_begin_process(void) {
43   jstring jhostName;
44   jstring jfunction;
45   jclass cls;
46   JNIEnv * env = get_current_thread_env();
47   jmethodID id =
48       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
49           "onBeginProcess",
50           "(Ljava/lang/String;Ljava/lang/String;)V");
51   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
52     return;
53   jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
54   jfunction =
55       (jstring) (*env)->NewStringUTF(env, A_surfxml_process_function);
56   (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
57 }
58
59 void japplication_handler_on_process_arg(void) {
60   jstring jarg;
61   jclass cls;
62   JNIEnv * env = get_current_thread_env();
63   jmethodID id =
64       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
65           "onProcessArg", "(Ljava/lang/String;)V");
66   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
67     return;
68   jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
69
70   (*env)->CallStaticVoidMethod(env, cls, id, jarg);
71 }
72
73 void japplication_handler_on_property(void) {
74   jstring jid;
75   jstring jvalue;
76   jclass cls;
77   JNIEnv * env = get_current_thread_env();
78   jmethodID id =
79       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
80           "onProperty",
81           "(Ljava/lang/String;Ljava/lang/String;)V");
82   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
83     return;
84
85   jid = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_id);
86   jvalue = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_value);
87   (*env)->CallStaticVoidMethod(env, cls, id, jid, jvalue);
88 }
89
90 void japplication_handler_on_end_process(void) {
91   JNIEnv * env = get_current_thread_env();
92   jclass cls;
93   jmethodID id =
94       jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
95           "onEndProcess", "()V");
96   if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
97     return;
98   (*env)->CallStaticVoidMethod(env, cls, id);
99 }