From 2f365a035bbf2eba1478f28218eac2062ea1248c Mon Sep 17 00:00:00 2001 From: cherierm Date: Fri, 11 Jul 2008 15:18:24 +0000 Subject: [PATCH] The JNI interface for the Java ApplicationHandler git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5868 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/java/jmsg_application_handler.c | 105 ++++++++++++++++++++++++++++ src/java/jmsg_application_handler.h | 38 ++++++++++ 2 files changed, 143 insertions(+) create mode 100644 src/java/jmsg_application_handler.c create mode 100644 src/java/jmsg_application_handler.h diff --git a/src/java/jmsg_application_handler.c b/src/java/jmsg_application_handler.c new file mode 100644 index 0000000000..f1e74bd5ec --- /dev/null +++ b/src/java/jmsg_application_handler.c @@ -0,0 +1,105 @@ +#include "jmsg_application_handler.h" + +#include "jmsg.h" + +#include "surf/surfxml_parse.h" +#include "jxbt_utilities.h" + + + + +void +japplication_handler_on_start_document(void) +{ + jclass cls; + JNIEnv * env = get_current_thread_env(); + + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onStartDocument", "()V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + (*env)->CallStaticVoidMethod(env, cls, id); +} + +void +japplication_handler_on_end_document(void) +{ + jclass cls; + JNIEnv * env = get_current_thread_env(); + + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onEndDocument", "()V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + (*env)->CallStaticVoidMethod(env, cls, id); +} + +void +japplication_handler_on_begin_process(void) +{ + jstring jhostName; + jstring jfunction; + jclass cls; + JNIEnv * env = get_current_thread_env(); + + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onBeginProcess", "(Ljava/lang/String;Ljava/lang/String;)V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + jhostName = (jstring)(*env)->NewStringUTF(env, A_surfxml_process_host); + jfunction = (jstring)(*env)->NewStringUTF(env, A_surfxml_process_function); + + (*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction); +} + +void +japplication_handler_on_process_arg(void) +{ + jstring jarg; + jclass cls; + JNIEnv * env = get_current_thread_env(); + + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onProcessArg", "(Ljava/lang/String;)V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + jarg = (jstring)(*env)->NewStringUTF(env, A_surfxml_argument_value); + + (*env)->CallStaticVoidMethod(env, cls, id, jarg); +} + +void +japplication_handler_on_property(void) +{ + jstring jid; + jstring jvalue; + jclass cls; + JNIEnv * env = get_current_thread_env(); + + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onProperty", "(Ljava/lang/String;Ljava/lang/String;)V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + jid = (jstring)(*env)->NewStringUTF(env, A_surfxml_prop_id); + jvalue = (jstring)(*env)->NewStringUTF(env, A_surfxml_prop_value); + + (*env)->CallStaticVoidMethod(env, cls, id, jid, jvalue); +} + +void +japplication_handler_on_end_process(void) +{ + JNIEnv * env = get_current_thread_env(); + jclass cls; + jmethodID id = jxbt_get_static_smethod(env,"simgrid/msg/ApplicationHandler","onEndProcess", "()V") ; + + if(!id || !(cls = jxbt_get_class(env , "simgrid/msg/ApplicationHandler"))) + return; + + (*env)->CallStaticVoidMethod(env, cls, id); +} \ No newline at end of file diff --git a/src/java/jmsg_application_handler.h b/src/java/jmsg_application_handler.h new file mode 100644 index 0000000000..e4ab86c240 --- /dev/null +++ b/src/java/jmsg_application_handler.h @@ -0,0 +1,38 @@ +/* + * $Id: jmsg_application_handler.h 3684 2007-07-08 20:51:53Z mquinson $ + * + * Copyright 2006,2007 Martin Quinson, Malek Cherier All right reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. + * + * This contains the declarations of the functions in relation with the java + * host instance. + */ + +#ifndef MSG_JAPPLICATION_HANDLER_H +#define MSG_JAPPLICATION_HANDLER_H + +#include +#include "msg/msg.h" + +void +japplication_handler_on_start_document(void); + +void +japplication_handler_on_end_document(void); + +void +japplication_handler_on_begin_process(void); + +void +japplication_handler_on_process_arg(void); + +void +japplication_handler_on_property(void); + +void +japplication_handler_on_end_process(void); + + +#endif /* !MSG_JAPPLICATION_HANDLER_H */ \ No newline at end of file -- 2.20.1