2 * Copyright 2006,2007,2010 Da SimGrid Team.
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.
7 * Upcalls to the Java functions used as callback to the FleXML application file parser.
10 #include "jmsg_application_handler.h"
14 #include "surf/surfxml_parse.h"
15 #include "jxbt_utilities.h"
16 void japplication_handler_on_start_document(void) {
18 JNIEnv * env = get_current_thread_env();
20 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
21 "onStartDocument", "()V");
23 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
26 (*env)->CallStaticVoidMethod(env, cls, id);
29 void japplication_handler_on_end_document(void) {
31 JNIEnv * env = get_current_thread_env();
33 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
34 "onEndDocument", "()V");
36 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
39 (*env)->CallStaticVoidMethod(env, cls, id);
42 void japplication_handler_on_begin_process(void) {
46 JNIEnv * env = get_current_thread_env();
48 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
50 "(Ljava/lang/String;Ljava/lang/String;)V");
51 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
53 jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
55 (jstring) (*env)->NewStringUTF(env, A_surfxml_process_function);
56 (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
59 void japplication_handler_on_process_arg(void) {
62 JNIEnv * env = get_current_thread_env();
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")))
68 jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
70 (*env)->CallStaticVoidMethod(env, cls, id, jarg);
73 void japplication_handler_on_property(void) {
77 JNIEnv * env = get_current_thread_env();
79 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
81 "(Ljava/lang/String;Ljava/lang/String;)V");
82 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
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);
90 void japplication_handler_on_end_process(void) {
91 JNIEnv * env = get_current_thread_env();
94 jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
95 "onEndProcess", "()V");
96 if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
98 (*env)->CallStaticVoidMethod(env, cls, id);