#include "msg/msg.h"
#include "msg/private.h"
#include "simix/private.h"
-#include "java/jxbt_context.h"
+#include "xbt/xbt_context_private.h"
#include "jmsg_process.h"
#include "jmsg_host.h"
#include "jmsg_channel.h"
#include "jxbt_utilities.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(jmsg,"MSG for Java(TM)");
-
#include "jmsg.h"
static JavaVM * __java_vm = NULL;
+static jobject
+native_to_java_process(m_process_t process);
+
JavaVM *
get_java_VM(void) {
return __java_vm;
return env;
}
+static jobject
+native_to_java_process(m_process_t process)
+{
+ return ((xbt_jcontext_t)(process->simdata->s_process->simdata->context))->jprocess;
+}
+
/*
* The MSG process connected functions implementation.
/*data*/ (void*)process,
jprocess,env,
&process->simdata->s_process);
+
+
DEBUG1("context created (s_process=%p)",process->simdata->s_process);
}
/* delete the global reference */
- jprocess_delete_global_ref(SIMIX_process_get_jprocess(process->simdata->s_process),env);
+ jprocess_delete_global_ref(native_to_java_process(process),env);
/* kill the native process (this wrapper is call by the destructor of the java
* process instance)
return NULL;
}
- if(!SIMIX_process_get_jprocess(process->simdata->s_process)) {
+ if(!native_to_java_process(process)) {
jxbt_throw_native(env, xbt_strdup("SIMIX_process_get_jprocess() failed"));
return NULL;
}
- return (jobject)SIMIX_process_get_jprocess(process->simdata->s_process);
+ return (jobject)(native_to_java_process(process));
}
return NULL;
}
- jprocess = SIMIX_process_get_jprocess(process->simdata->s_process);
+ jprocess = native_to_java_process(process);
if(!jprocess)
jxbt_throw_native(env, xbt_strdup("SIMIX_process_get_jprocess() failed"));
}
process = MSG_task_get_sender(task);
- return SIMIX_process_get_jprocess(process->simdata->s_process);
+ return (jobject)native_to_java_process(process);
}
JNIEXPORT jobject JNICALL
process = MSG_task_get_sender(task);
- return SIMIX_process_get_jprocess(process->simdata->s_process);
+ return (jobject)native_to_java_process(process);
}
JNIEXPORT jobject JNICALL
return;
}
- jcontext_exit(process->simdata->s_process->simdata->context,0,get_current_thread_env());
+ xbt_context_stop(0);
}
JNIEXPORT void JNICALL
return jtable;
}
+
+JNIEXPORT void JNICALL
+Java_simgrid_msg_Msg_selectContextFactory(JNIEnv * env, jclass class,jstring jname)
+{
+ int rv;
+
+ /* get the C string from the java string*/
+ const char* name = (*env)->GetStringUTFChars(env, jname, 0);
+
+ rv = xbt_context_select_factory(name);
+
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+
+ if(rv)
+ jxbt_throw_native(env, xbt_strdup("xbt_select_context_factory() failed"));
+}