Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Forgot to update migrate signature in Process
[simgrid.git] / src / jmsg_application_handler.c
1 /* Upcalls to the Java functions used as callback to the FleXML parser.     */
2
3 /* Copyright (c) 2008, 2009, 2010. 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 #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 {
17   jclass cls;
18   JNIEnv *env = get_current_thread_env();
19   jmethodID id =
20       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
21                               "onStartDocument", "()V");
22
23   if (!id
24       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
25     return;
26
27   (*env)->CallStaticVoidMethod(env, cls, id);
28 }
29
30 void japplication_handler_on_end_document(void)
31 {
32   jclass cls;
33   JNIEnv *env = get_current_thread_env();
34   jmethodID id =
35       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
36                               "onEndDocument", "()V");
37
38   if (!id
39       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
40     return;
41
42   (*env)->CallStaticVoidMethod(env, cls, id);
43 }
44
45 void japplication_handler_on_begin_process(void)
46 {
47   jstring jhostName;
48   jstring jfunction;
49   jclass cls;
50   JNIEnv *env = get_current_thread_env();
51   jmethodID id =
52       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
53                               "onBeginProcess",
54                               "(Ljava/lang/String;Ljava/lang/String;)V");
55   if (!id
56       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
57     return;
58   jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
59   jfunction =
60       (jstring) (*env)->NewStringUTF(env, A_surfxml_process_function);
61   (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
62 }
63
64 void japplication_handler_on_process_arg(void)
65 {
66   jstring jarg;
67   jclass cls;
68   JNIEnv *env = get_current_thread_env();
69   jmethodID id =
70       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
71                               "onProcessArg", "(Ljava/lang/String;)V");
72   if (!id
73       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
74     return;
75   jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
76
77   (*env)->CallStaticVoidMethod(env, cls, id, jarg);
78 }
79
80 void japplication_handler_on_property(void)
81 {
82   jstring jid;
83   jstring jvalue;
84   jclass cls;
85   JNIEnv *env = get_current_thread_env();
86   jmethodID id =
87       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
88                               "onProperty",
89                               "(Ljava/lang/String;Ljava/lang/String;)V");
90   if (!id
91       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
92     return;
93
94   jid = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_id);
95   jvalue = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_value);
96   (*env)->CallStaticVoidMethod(env, cls, id, jid, jvalue);
97 }
98
99 void japplication_handler_on_end_process(void)
100 {
101   JNIEnv *env = get_current_thread_env();
102   jclass cls;
103   jmethodID id =
104       jxbt_get_static_smethod(env, "org/simgrid/msg/ApplicationHandler",
105                               "onEndProcess", "()V");
106   if (!id
107       || !(cls = jxbt_get_class(env, "org/simgrid/msg/ApplicationHandler")))
108     return;
109   (*env)->CallStaticVoidMethod(env, cls, id);
110 }