1 /* Upcalls to the Java functions used as callback to the FleXML parser. */
3 /* Copyright (c) 2008, 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. */
9 #include "jmsg_application_handler.h"
13 #include "surf/surfxml_parse.h"
14 #include "jxbt_utilities.h"
15 void japplication_handler_on_start_document(void) {
17 JNIEnv * env = get_current_thread_env();
19 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
20 "onStartDocument", "()V");
22 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
25 (*env)->CallStaticVoidMethod(env, cls, id);
28 void japplication_handler_on_end_document(void) {
30 JNIEnv * env = get_current_thread_env();
32 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
33 "onEndDocument", "()V");
35 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
38 (*env)->CallStaticVoidMethod(env, cls, id);
41 void japplication_handler_on_begin_process(void) {
45 JNIEnv * env = get_current_thread_env();
47 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
49 "(Ljava/lang/String;Ljava/lang/String;)V");
50 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
52 jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
54 (jstring) (*env)->NewStringUTF(env, A_surfxml_process_function);
55 (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
58 void japplication_handler_on_process_arg(void) {
61 JNIEnv * env = get_current_thread_env();
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")))
67 jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
69 (*env)->CallStaticVoidMethod(env, cls, id, jarg);
72 void japplication_handler_on_property(void) {
76 JNIEnv * env = get_current_thread_env();
78 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
80 "(Ljava/lang/String;Ljava/lang/String;)V");
81 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
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);
89 void japplication_handler_on_end_process(void) {
90 JNIEnv * env = get_current_thread_env();
93 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
94 "onEndProcess", "()V");
95 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
97 (*env)->CallStaticVoidMethod(env, cls, id);