You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/01/23 00:47:21 UTC
[48/51] [partial] incubator-reef git commit: [REEF-93] Move java
sources to lang/java
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp
new file mode 100644
index 0000000..0a9353d
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp
@@ -0,0 +1,492 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#include "InteropReturnInfo.h"
+#include "Clr2JavaImpl.h"
+#include "InteropLogger.h"
+#include "BinaryUtil.h"
+#include "malloc.h"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Collections::Generic;
+using namespace System::Runtime::InteropServices;
+using namespace System::Reflection;
+using namespace Microsoft::Reef::Driver::Bridge;
+
+ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+};
+
+static void MarshalErrorToJava (
+ JNIEnv *env,
+ jobject jerrorInfo,
+ int errorNo,
+ String^ exceptionString
+) {
+ jclass objectClass;
+ jfieldID fieldID;
+
+ objectClass = env->GetObjectClass(jerrorInfo);
+ fieldID = env->GetFieldID(objectClass, "errorNo", "I");
+ env->SetIntField (jerrorInfo, fieldID, errorNo);
+
+ pin_ptr<const wchar_t> wchExceptionString = PtrToStringChars(exceptionString);
+ jstring jexceptionString = env->NewString((const jchar*)wchExceptionString, exceptionString->Length);
+ fieldID = env->GetFieldID(objectClass, "exceptionString", "Ljava/lang/String;");
+ env->SetObjectField(jerrorInfo, fieldID, jexceptionString);
+}
+
+
+// Loading Clr Assembly. Note that we do not use ManagerLogger in this method since the
+// logger assembly needs to be loaded by this method before it can be used.
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_loadClrAssembly
+(
+ JNIEnv *env,
+ jclass tobj,
+ jstring jfileName) {
+ try {
+ Console::Write("+Java_org_apache_reef_javabridge_NativeInterop_loadClrAssembly: ");
+ const wchar_t* charAsmName = UnicodeCppStringFromJavaString (env, jfileName);
+ int len = env->GetStringLength(jfileName);
+ wchar_t* fileName = (wchar_t* )_alloca((len + 2) * sizeof(wchar_t));
+ memcpy(fileName, charAsmName, (len + 2)* sizeof(wchar_t));
+ fileName[len] = 0;
+ String^ asmName = ManagedStringFromJavaString(env, jfileName);
+ Console::WriteLine("loading " + asmName);
+
+ BINARY_TYPE binaryType = IsManagedBinary(fileName);
+ if (binaryType == BINARY_TYPE_CLR) {
+ System::Reflection::Assembly^ asm1 = Assembly::LoadFrom(asmName);
+ AssemblyUtil::Add(asm1);
+ }
+ else if (binaryType == BINARY_TYPE_NATIVE) {
+ HANDLE handle = LoadLibraryW(fileName);
+ }
+ }
+ catch (System::Exception^ ex) {
+ // We do not propagate the exception back to Java to stop driver here
+ // since failure to load an assembly is not necesary devastating
+ Console::Write("Exceptions in Java_org_apache_reef_javabridge_NativeInterop_loadClrAssembly");
+ Console::Write(ex->Message);
+ Console::Write(ex->StackTrace);
+ }
+
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: CallClrSystemOnStartHandler
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT jlongArray JNICALL Java_org_apache_reef_javabridge_NativeInterop_CallClrSystemOnStartHandler
+(JNIEnv * env, jclass jclassx, jstring dateTimeString, jstring httpServerPort) {
+ try {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_CallClrSystemOnStartHandler");
+ const wchar_t* charConfig = UnicodeCppStringFromJavaString (env, dateTimeString);
+ int lenConfig = env->GetStringLength(dateTimeString);
+ String^ strConfig = Marshal::PtrToStringUni((IntPtr)(unsigned short*) charConfig, lenConfig);
+ DateTime dt = DateTime::Now;
+
+ const wchar_t* charPort = UnicodeCppStringFromJavaString (env, httpServerPort);
+ int lenPort = env->GetStringLength(httpServerPort);
+ String^ strPort = Marshal::PtrToStringUni((IntPtr)(unsigned short*) charPort, lenPort);
+
+ array<unsigned long long>^ handlers = ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart(dt, strPort);
+ return JavaLongArrayFromManagedLongArray(env, handlers);
+ }
+ catch (System::Exception^ ex) {
+ // we cannot get error back to java here since we don't have an object to call back (although we idealy should...)
+ ManagedLog::LOGGER->LogError("Exceptions in Java_org_apache_reef_javabridge_NativeInterop_CallClrSystemOnStartHandler", ex);
+ return NULL;
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemAllocatedEvaluatorHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/AllocatedEvaluatorBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemAllocatedEvaluatorHandlerOnNext
+(JNIEnv *env, jclass cls, jlong handle, jobject jallocatedEvaluatorBridge, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemAllocatedEvaluatorHandlerOnNext:");
+ AllocatedEvaluatorClr2Java^ allocatedEval = gcnew AllocatedEvaluatorClr2Java(env, jallocatedEvaluatorBridge);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemAllocatedEvaluatorHandler_OnNext(handle, allocatedEval);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemAllocatedEvaluatorHandler_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ allocatedEval -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemActiveContextHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/ActiveContextBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemActiveContextHandlerOnNext
+(JNIEnv *env, jclass cls, jlong handle, jobject jactiveContextBridge, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemActiveContextHandlerOnNext");
+ ActiveContextClr2Java^ activeContextBrdige = gcnew ActiveContextClr2Java(env, jactiveContextBridge);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemActiveContextHandler_OnNext(handle, activeContextBrdige);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemActiveContextHandler_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ activeContextBrdige -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemEvaluatorRequstorHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/EvaluatorRequstorBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemEvaluatorRequstorHandlerOnNext
+(JNIEnv *env, jclass cls, jlong handle, jobject jevaluatorRequestorBridge, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemEvaluatorRequstorHandlerOnNext");
+ EvaluatorRequestorClr2Java^ evaluatorRequestorBridge = gcnew EvaluatorRequestorClr2Java(env, jevaluatorRequestorBridge);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemEvaluatorRequestor_OnNext(handle, evaluatorRequestorBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemEvaluatorRequestor_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ evaluatorRequestorBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemTaskMessageHandlerOnNext
+ * Signature: (J[BLorg/apache/reef/javabridge/TaskMessageBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemTaskMessageHandlerOnNext
+(JNIEnv *env, jclass cls, jlong handle, jbyteArray jmessage, jobject jtaskMessageBridge, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemTaskMessageHandlerOnNext");
+ TaskMessageClr2Java^ taskMesageBridge = gcnew TaskMessageClr2Java(env, jtaskMessageBridge);
+ array<byte>^ message = ManagedByteArrayFromJavaByteArray(env, jmessage);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemTaskMessage_OnNext(handle, taskMesageBridge, message);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemTaskMessage_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ taskMesageBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSysteFailedTaskHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/FailedTaskBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedTaskHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jfailedTask, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedTaskHandlerOnNext");
+ FailedTaskClr2Java^ failedTaskBridge = gcnew FailedTaskClr2Java(env, jfailedTask);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemFailedTask_OnNext(handler, failedTaskBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemTaskMessage_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ failedTaskBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSysteFailedTaskHandlerOnNext
+ * Signature: (JLorg.apache.reef.javabridge/FailedTaskBridge;Lorg.apache.reef.javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemRunningTaskHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jrunningTask, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemRunningTaskHandlerOnNext");
+ RunningTaskClr2Java^ runningTaskBridge = gcnew RunningTaskClr2Java(env, jrunningTask);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemRunningTask_OnNext(handler, runningTaskBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemRunningTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ runningTaskBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemFailedEvaluatorHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/FailedEvaluatorBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedEvaluatorHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jfailedEvaluator, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedEvaluatorHandlerOnNext");
+ FailedEvaluatorClr2Java^ failedEvaluatorBridge = gcnew FailedEvaluatorClr2Java(env, jfailedEvaluator);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemFailedEvaluator_OnNext(handler, failedEvaluatorBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemFailedEvaluator_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ failedEvaluatorBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemHttpServerEventHandlerOnHttpRequest
+ * Signature: (JLorg/apache/reef/javabridge/HttpServerEventBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemHttpServerHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jhttpServerEventBridge, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemHttpServerHandlerOnNext");
+ HttpServerClr2Java^ httpServerClr2Java = gcnew HttpServerClr2Java(env, jhttpServerEventBridge);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemHttpServer_OnNext(handler, httpServerClr2Java);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemHttpServer_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ httpServerClr2Java -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemCompletedTaskHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/CompletedTaskBridge;Lorg/apache/reef/javabridge/InteropLogger;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemCompletedTaskHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jcompletedTask, jobject jlogger) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemCompletedTaskHandlerOnNext");
+ CompletedTaskClr2Java^ completedTaskBridge = gcnew CompletedTaskClr2Java(env, jcompletedTask);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemCompletedTask_OnNext(handler, completedTaskBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemCompletedTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ completedTaskBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrBufferedLog
+ * Signature: (ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrBufferedLog
+(JNIEnv *env, jclass cls, jint logLevel, jstring message) {
+ try {
+ if (!JavaClrBridge::LoggerWrapper::initialized) {
+ ManagedLog::LOGGER->Log("Initializing CLRBufferedLogHandler in java bridge...");
+ JavaClrBridge::LoggerWrapper::logger->Listeners->Add(gcnew System::Diagnostics::ConsoleTraceListener());
+ JavaClrBridge::LoggerWrapper::initialized = true;
+ }
+
+ System::Diagnostics::TraceEventType eventType;
+ switch (logLevel) {
+ case 0:
+ eventType = System::Diagnostics::TraceEventType::Stop;
+ break;
+ case 1:
+ eventType = System::Diagnostics::TraceEventType::Error;
+ break;
+ case 2:
+ eventType = System::Diagnostics::TraceEventType::Warning;
+ break;
+ case 3:
+ eventType = System::Diagnostics::TraceEventType::Information;
+ break;
+ case 4:
+ eventType = System::Diagnostics::TraceEventType::Verbose;
+ break;
+ default:
+ eventType = System::Diagnostics::TraceEventType::Information;
+ break;
+
+ }
+
+ String^ msg = ManagedStringFromJavaString(env, message);
+ msg = System::String::Concat(System::DateTime::Now, msg);
+ JavaClrBridge::LoggerWrapper::logger->TraceEvent(eventType, 0, msg);
+ }
+ catch (System::Exception^ ex) {
+ ManagedLog::LOGGER->LogError("Exception in Java_javabridge_NativeInterop_ClrBufferedLog", ex);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemSupendedTaskHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/SuspendedTaskBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemSupendedTaskHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jsuspendedTask) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemSupendedTaskHandlerOnNext");
+ SuspendedTaskClr2Java^ suspendedTaskBridge = gcnew SuspendedTaskClr2Java(env, jsuspendedTask);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemSuspendedTask_OnNext(handler, suspendedTaskBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemSuspendedTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ suspendedTaskBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemCompletdEvaluatorHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/CompletedEvaluatorBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemCompletdEvaluatorHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jcompletedEvaluator) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemCompletdEvaluatorHandlerOnNext");
+ CompletedEvaluatorClr2Java^ completedEvaluatorBridge = gcnew CompletedEvaluatorClr2Java(env, jcompletedEvaluator);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemCompletedEvaluator_OnNext(handler, completedEvaluatorBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemSuspendedTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ completedEvaluatorBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemClosedContextHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/ClosedContextBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemClosedContextHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jclosedContext) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemClosedContextHandlerOnNext");
+ ClosedContextClr2Java^ closedContextBridge = gcnew ClosedContextClr2Java(env, jclosedContext);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemClosedContext_OnNext(handler, closedContextBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemClosedContext_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ closedContextBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemFailedContextHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/FailedContextBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedContextHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jfailedContext) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemFailedContextHandlerOnNext");
+ FailedContextClr2Java^ failedContextBridge = gcnew FailedContextClr2Java(env, jfailedContext);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemFailedContext_OnNext(handler, failedContextBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemFailedContext_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ failedContextBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemContextMessageHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/ContextMessageBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemContextMessageHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jcontextMessage) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemContextMessageHandlerOnNext");
+ ContextMessageClr2Java^ contextMessageBridge = gcnew ContextMessageClr2Java(env, jcontextMessage);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemContextMessage_OnNext(handler, contextMessageBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemContextMessage_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ contextMessageBridge -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemDriverRestartHandlerOnNext
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartHandlerOnNext");
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemDriverRestart_OnNext(handler);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemContextMessage_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ // we do not call back to Java for exception in .NET restart handler
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemDriverRestartActiveContextHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/ActiveContextBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartActiveContextHandlerOnNext
+(JNIEnv *env, jclass cls, jlong handle, jobject jactiveContextBridge) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartActiveContextHandlerOnNext");
+ ActiveContextClr2Java^ activeContextBrdige = gcnew ActiveContextClr2Java(env, jactiveContextBridge);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartActiveContextHandler_OnNext(handle, activeContextBrdige);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemDriverRestartActiveContextHandler_OnNext";
+ ManagedLog::LOGGER -> LogError(errorMessage, ex);
+ activeContextBrdige -> OnError(errorMessage);
+ }
+}
+
+/*
+ * Class: org_apache_reef_javabridge_NativeInterop
+ * Method: ClrSystemDriverRestartRunningTaskHandlerOnNext
+ * Signature: (JLorg/apache/reef/javabridge/RunningTaskBridge;)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartRunningTaskHandlerOnNext
+(JNIEnv *env , jclass cls, jlong handler, jobject jrunningTask) {
+ ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_ClrSystemDriverRestartRunningTaskHandlerOnNext");
+ RunningTaskClr2Java^ runningTaskBridge = gcnew RunningTaskClr2Java(env, jrunningTask);
+ try {
+ ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartRunningTask_OnNext(handler, runningTaskBridge);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in Call_ClrSystemDriverRestartRunningTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ runningTaskBridge -> OnError(errorMessage);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h
new file mode 100644
index 0000000..61d9d0a
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// JavaClrBridge.h
+
+#pragma once
+
+using namespace System;
+
+namespace JavaClrBridge {
+ ref class LoggerWrapper
+ {
+ public:
+ static System::Diagnostics::TraceSource^ logger =
+ gcnew System::Diagnostics::TraceSource("JavaCLRBridgeLogger", System::Diagnostics::SourceLevels::All);
+ static bool initialized = false;
+ };
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln
new file mode 100644
index 0000000..d4b2aec
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln
@@ -0,0 +1,56 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaClrBridge", "JavaClrBridge.vcxproj", "{2825FD53-350B-4294-8CFC-8DD2F4F4F285}"
+ ProjectSection(ProjectDependencies) = postProject
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD} = {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClrHandler", "..\..\..\CSharp\CSharp\ClrHandler\ClrHandler.csproj", "{443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Mixed Platforms.ActiveCfg = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Mixed Platforms.Build.0 = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Mixed Platforms.Deploy.0 = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|Win32.Build.0 = Debug|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|x64.ActiveCfg = Debug|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Debug|x64.Build.0 = Debug|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|Any CPU.ActiveCfg = Release|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|Mixed Platforms.ActiveCfg = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|Mixed Platforms.Build.0 = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|Win32.ActiveCfg = Release|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|Win32.Build.0 = Release|Win32
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|x64.ActiveCfg = Release|x64
+ {2825FD53-350B-4294-8CFC-8DD2F4F4F285}.Release|x64.Build.0 = Release|x64
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Debug|x64.Build.0 = Debug|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|Win32.ActiveCfg = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|x64.ActiveCfg = Release|Any CPU
+ {443A7B61-5C91-4F67-9FCD-81BC6FABFDBD}.Release|x64.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj
new file mode 100644
index 0000000..08412d1
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)'==''">
+ <Configuration>Release</Configuration>
+ </PropertyGroup>
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="DefaultDirectories">
+ <JAVA_HOME Condition=" '$(JAVA_HOME)' == '' ">c:\progra~1\java\jdk1.7.0_40</JAVA_HOME>
+ </PropertyGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2825FD53-350B-4294-8CFC-8DD2F4F4F285}</ProjectGuid>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <Keyword>ManagedCProj</Keyword>
+ <RootNamespace>Microsoft.Reef.Interop</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalUsingDirectories>..\..\..\..\..\target\classes</AdditionalUsingDirectories>
+ <AdditionalIncludeDirectories>..\..\..\..\..\..\reef-bridge-java\target\classes;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <OutputFile>..\..\..\..\..\target\classes\$(TargetName)$(TargetExt)</OutputFile>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="BinaryUtil.h" />
+ <ClInclude Include="Clr2JavaImpl.h" />
+ <ClInclude Include="InteropAssemblies.h" />
+ <ClInclude Include="InteropLogger.h" />
+ <ClInclude Include="InteropReturnInfo.h" />
+ <ClInclude Include="InteropUtil.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="ActiveContextClr2Java.cpp" />
+ <ClCompile Include="AllocatedEvaluatorClr2Java.cpp" />
+ <ClCompile Include="AssemblyInfo.cpp" />
+ <ClCompile Include="AssemblyUtil.cpp" />
+ <ClCompile Include="BinaryUtil.cpp" />
+ <ClCompile Include="ClosedContextClr2Java.cpp" />
+ <ClCompile Include="CommonUtilities.cpp" />
+ <ClCompile Include="CompletedEvaluatorClr2Java.cpp" />
+ <ClCompile Include="CompletedTaskClr2Java.cpp" />
+ <ClCompile Include="ContextMessageClr2Java.cpp" />
+ <ClCompile Include="EvaluatorRequestorClr2Java.cpp" />
+ <ClCompile Include="FailedContextClr2Java.cpp" />
+ <ClCompile Include="FailedEvaluatorClr2Java.cpp" />
+ <ClCompile Include="FailedTaskClr2Java.cpp" />
+ <ClCompile Include="HttpServerClr2Java.cpp" />
+ <ClCompile Include="InteropLogger.cpp" />
+ <ClCompile Include="InteropReturnInfo.cpp" />
+ <ClCompile Include="InteropUtil.cpp" />
+ <ClCompile Include="JavaClrBridge.cpp" />
+ <ClCompile Include="RunningTaskClr2Java.cpp" />
+ <ClCompile Include="SuspendedTaskClr2Java.cpp" />
+ <ClCompile Include="TaskMessageClr2Java.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters
new file mode 100644
index 0000000..5421846
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="InteropUtil.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="InteropAssemblies.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="InteropReturnInfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="InteropLogger.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Clr2JavaImpl.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="BinaryUtil.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="JavaClrBridge.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="AssemblyInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="InteropUtil.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="AssemblyUtil.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="InteropReturnInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="InteropLogger.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="AllocatedEvaluatorClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ActiveContextClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="EvaluatorRequestorClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="TaskMessageClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="BinaryUtil.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="FailedTaskClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="FailedEvaluatorClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="HttpServerClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="CompletedTaskClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="RunningTaskClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="SuspendedTaskClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="CompletedEvaluatorClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ClosedContextClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="CommonUtilities.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="FailedContextClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ContextMessageClr2Java.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp
new file mode 100644
index 0000000..62e30b3
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+using namespace JavaClrBridge;
+
+namespace Microsoft
+{
+ namespace Reef
+ {
+ namespace Driver
+ {
+ namespace Bridge
+ {
+ ManagedLogger::ManagedLogger(String^ className)
+ {
+ _logger = BridgeLogger::GetLogger(className);
+ }
+ BridgeLogger^ ManagedLogger::GetLogger(String^ className)
+ {
+ if(_logger == nullptr)
+ {
+ _logger = BridgeLogger::GetLogger(className);
+ }
+ return _logger;
+ }
+
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt
new file mode 100644
index 0000000..4e1b52f
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt
@@ -0,0 +1,57 @@
+====
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+====
+
+========================================================================
+ DYNAMIC LINK LIBRARY : JavaClrBridge Project Overview
+========================================================================
+
+AppWizard has created this JavaClrBridge DLL for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your JavaClrBridge application.
+
+JavaClrBridge.vcxproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+JavaClrBridge.vcxproj.filters
+ This is the filters file for VC++ projects generated using an Application Wizard.
+ It contains information about the association between the files in your project
+ and the filters. This association is used in the IDE to show grouping of files with
+ similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+ "Source Files" filter).
+
+JavaClrBridge.cpp
+ This is the main DLL source file.
+
+JavaClrBridge.h
+ This file contains a class declaration.
+
+AssemblyInfo.cpp
+ Contains custom attributes for modifying assembly metadata.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/RunningTaskClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/RunningTaskClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/RunningTaskClr2Java.cpp
new file mode 100644
index 0000000..7ef6f08
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/RunningTaskClr2Java.cpp
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+ RunningTaskClr2Java::RunningTaskClr2Java(JNIEnv *env, jobject jobjectRunningTask) {
+ ManagedLog::LOGGER->LogStart("RunningTaskClr2Java::RunningTaskClr2Java");
+
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectRunningTask = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectRunningTask));
+
+ jclass jclassRunningTask = env->GetObjectClass (_jobjectRunningTask);
+ jmethodID jmidGetId = env->GetMethodID(jclassRunningTask, "getId", "()Ljava/lang/String;");
+
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env -> CallObjectMethod(_jobjectRunningTask, jmidGetId)));
+ ManagedLog::LOGGER->LogStop("RunningTaskClr2Java::RunningTaskClr2Java");
+ }
+
+ IActiveContextClr2Java^ RunningTaskClr2Java::GetActiveContext() {
+ ManagedLog::LOGGER->LogStart("RunningTaskClr2Java::GetActiveContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassRunningTask = env->GetObjectClass(_jobjectRunningTask);
+ jfieldID jidActiveContext = env->GetFieldID(jclassRunningTask, "jactiveContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectActiveContext = env->GetObjectField(_jobjectRunningTask, jidActiveContext);
+ ManagedLog::LOGGER->LogStop("RunningTaskClr2Java::GetActiveContext");
+
+ return gcnew ActiveContextClr2Java(env, jobjectActiveContext);
+ }
+
+ String^ RunningTaskClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("RunningTaskClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+
+ void RunningTaskClr2Java::Send(array<byte>^ message) {
+ ManagedLog::LOGGER->LogStart("RunningTaskClr2Java::Send");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclassRunningTask = env->GetObjectClass(_jobjectRunningTask);
+ jmethodID jmidSend = env->GetMethodID(jclassRunningTask, "send", "([B)V");
+
+
+ if (jmidSend == NULL) {
+ ManagedLog::LOGGER->Log("jmidSend is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jobjectRunningTask,
+ jmidSend,
+ JavaByteArrayFromManagedByteArray(env, message));
+ ManagedLog::LOGGER->LogStop("RunningTaskClr2Java::Send");
+ }
+
+ void RunningTaskClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("RunningTaskClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectRunningTask);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/SuspendedTaskClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/SuspendedTaskClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/SuspendedTaskClr2Java.cpp
new file mode 100644
index 0000000..695e2b3
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/SuspendedTaskClr2Java.cpp
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ SuspendedTaskClr2Java::SuspendedTaskClr2Java(JNIEnv *env, jobject jobjectSuspendedTask) {
+ ManagedLog::LOGGER->LogStart("SuspendedTaskClr2Java::SuspendedTaskClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectSuspendedTask = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectSuspendedTask));
+
+ jclass jclassSuspendedTask = env->GetObjectClass (_jobjectSuspendedTask);
+ jfieldID jidTaskId = env->GetFieldID(jclassSuspendedTask, "taskId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectSuspendedTask, jidTaskId)));
+ ManagedLog::LOGGER->LogStop("SuspendedTaskClr2Java::SuspendedTaskClr2Java");
+ }
+
+ IActiveContextClr2Java^ SuspendedTaskClr2Java::GetActiveContext() {
+ ManagedLog::LOGGER->LogStart("SuspendedTaskClr2Java::GetActiveContext");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassSuspendedTask = env->GetObjectClass (_jobjectSuspendedTask);
+ jfieldID jidActiveContext = env->GetFieldID(jclassSuspendedTask, "jactiveContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectActiveContext = env->GetObjectField(_jobjectSuspendedTask, jidActiveContext);
+ ManagedLog::LOGGER->LogStop("SuspendedTaskClr2Java::GetActiveContext");
+ return gcnew ActiveContextClr2Java(env, jobjectActiveContext);
+ }
+
+ String^ SuspendedTaskClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("SuspendedTaskClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+
+ array<byte>^ SuspendedTaskClr2Java::Get() {
+ ManagedLog::LOGGER->Log("SuspendedTaskClr2Java::Get");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclassSuspendedTask = env->GetObjectClass (_jobjectSuspendedTask);
+ jmethodID jmidGet = env->GetMethodID(jclassSuspendedTask, "get", "()[B");
+
+ if (jmidGet == NULL) {
+ ManagedLog::LOGGER->Log("jmidGet is NULL");
+ return nullptr;
+ }
+ jbyteArray jMessage = (jbyteArray) env->CallObjectMethod(_jobjectSuspendedTask, jmidGet);
+ return ManagedByteArrayFromJavaByteArray(env, jMessage);
+ }
+
+ void SuspendedTaskClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("SuspendedTaskClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectSuspendedTask);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/TaskMessageClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/TaskMessageClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/TaskMessageClr2Java.cpp
new file mode 100644
index 0000000..01d9471
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/TaskMessageClr2Java.cpp
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ TaskMessageClr2Java::TaskMessageClr2Java(JNIEnv *env, jobject jtaskMessage) {
+ ManagedLog::LOGGER->LogStart("TaskMessageClr2Java::TaskMessageClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectTaskMessage = reinterpret_cast<jobject>(env->NewGlobalRef(jtaskMessage));
+
+ jclass jclassTaskMessage = env->GetObjectClass (_jobjectTaskMessage);
+ jfieldID jidTaskId = env->GetFieldID(jclassTaskMessage, "taskId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectTaskMessage, jidTaskId)));
+ ManagedLog::LOGGER->LogStop("TaskMessageClr2Java::TaskMessageClr2Java");
+ }
+
+ void TaskMessageClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("TaskMessageClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectTaskMessage);
+ }
+
+ String^ TaskMessageClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("TaskMessageClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/pom.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/pom.xml b/lang/java/reef-bridge-project/reef-bridge-java/pom.xml
new file mode 100644
index 0000000..c383190
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/pom.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>reef-bridge-java</artifactId>
+ <name>REEF Bridge Java</name>
+ <description>Bridge between JVM and CLR.</description>
+
+
+ <parent>
+ <groupId>org.apache.reef</groupId>
+ <artifactId>reef-bridge-project</artifactId>
+ <version>0.11.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-runtime-local</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-runtime-yarn</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-io</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-checkpoint</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>reef-webserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.avro</groupId>
+ <artifactId>avro</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>false</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ <mainClass>org.apache.reef.javabridge.JavaBridge</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <exportAntProperties>true</exportAntProperties>
+ <target>
+ <property name="runtime_classpath" refid="maven.compile.classpath"/>
+ <exec executable="javah">
+ <arg value="-cp"/>
+ <arg value="${runtime_classpath}"/>
+ <arg value="-d"/>
+ <arg value="${project.build.directory}/classes"/>
+ <arg value="org.apache.reef.javabridge.NativeInterop"/>
+ </exec>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ActiveContextBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ActiveContextBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ActiveContextBridge.java
new file mode 100644
index 0000000..a0dedf5
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ActiveContextBridge.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.tang.ClassHierarchy;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.formats.AvroConfigurationSerializer;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class ActiveContextBridge extends NativeBridge implements Identifiable {
+ private static final Logger LOG = Logger.getLogger(ActiveContextBridge.class.getName());
+
+ private ActiveContext jactiveContext;
+
+ private AvroConfigurationSerializer serializer;
+
+ private String contextId;
+
+ private String evaluatorId;
+
+ public ActiveContextBridge(ActiveContext activeContext) {
+ jactiveContext = activeContext;
+ serializer = new AvroConfigurationSerializer();
+ contextId = activeContext.getId();
+ evaluatorId = activeContext.getEvaluatorId();
+ }
+
+ public void submitTaskString(final String taskConfigurationString) {
+
+ if (taskConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty taskConfigurationString provided.");
+ }
+ ClassHierarchy clrClassHierarchy = Utilities.loadClassHierarchy(NativeInterop.CLASS_HIERARCHY_FILENAME);
+ Configuration taskConfiguration;
+ try {
+ taskConfiguration = serializer.fromString(taskConfigurationString, clrClassHierarchy);
+ } catch (final Exception e) {
+ final String message = "Unable to de-serialize CLR task configurations using class hierarchy.";
+ LOG.log(Level.SEVERE, message, e);
+ throw new RuntimeException(message, e);
+ }
+ jactiveContext.submitTask(taskConfiguration);
+ }
+
+ public String getEvaluatorDescriptorSring() {
+ final String descriptorString = Utilities.getEvaluatorDescriptorString(jactiveContext.getEvaluatorDescriptor());
+ LOG.log(Level.FINE, "active context - serialized evaluator descriptor: " + descriptorString);
+ return descriptorString;
+ }
+
+ @Override
+ public void close() {
+ jactiveContext.close();
+ }
+
+ @Override
+ public String getId() {
+ return contextId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/AllocatedEvaluatorBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/AllocatedEvaluatorBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/AllocatedEvaluatorBridge.java
new file mode 100644
index 0000000..5d88355
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/AllocatedEvaluatorBridge.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.tang.ClassHierarchy;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.formats.AvroConfigurationSerializer;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class AllocatedEvaluatorBridge extends NativeBridge {
+
+ private static final Logger LOG = Logger.getLogger(AllocatedEvaluatorBridge.class.getName());
+
+ private final AllocatedEvaluator jallocatedEvaluator;
+ private final AvroConfigurationSerializer serializer;
+ private final ClassHierarchy clrClassHierarchy;
+ private final String evaluatorId;
+ private final String nameServerInfo;
+
+ public AllocatedEvaluatorBridge(final AllocatedEvaluator allocatedEvaluator, final String serverInfo) {
+ jallocatedEvaluator = allocatedEvaluator;
+ serializer = new AvroConfigurationSerializer();
+ clrClassHierarchy = Utilities.loadClassHierarchy(NativeInterop.CLASS_HIERARCHY_FILENAME);
+ evaluatorId = allocatedEvaluator.getId();
+ nameServerInfo = serverInfo;
+ }
+
+ public void submitContextAndTaskString(final String contextConfigurationString, final String taskConfigurationString) {
+ if (contextConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty contextConfigurationString provided.");
+ }
+ if (taskConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty taskConfigurationString provided.");
+ }
+ Configuration contextConfiguration;
+ Configuration taskConfiguration;
+ try {
+ contextConfiguration = serializer.fromString(contextConfigurationString, clrClassHierarchy);
+ taskConfiguration = serializer.fromString(taskConfigurationString, clrClassHierarchy);
+ } catch (final Exception e) {
+ final String message = "Unable to de-serialize CLR context or task configurations using class hierarchy.";
+ LOG.log(Level.SEVERE, message, e);
+ throw new RuntimeException(message, e);
+ }
+ jallocatedEvaluator.submitContextAndTask(contextConfiguration, taskConfiguration);
+ }
+
+ public void submitContextString(final String contextConfigurationString) {
+ if (contextConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty contextConfigurationString provided.");
+ }
+ Configuration contextConfiguration;
+ try {
+ contextConfiguration = serializer.fromString(contextConfigurationString, clrClassHierarchy);
+ } catch (final Exception e) {
+ final String message = "Unable to de-serialize CLR context configurations using class hierarchy.";
+ LOG.log(Level.SEVERE, message, e);
+ throw new RuntimeException(message, e);
+ }
+ jallocatedEvaluator.submitContext(contextConfiguration);
+ }
+
+ public void submitContextAndServiceString(final String contextConfigurationString, final String serviceConfigurationString) {
+ if (contextConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty contextConfigurationString provided.");
+ }
+ if (serviceConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty serviceConfigurationString provided.");
+ }
+
+ Configuration contextConfiguration;
+ Configuration servicetConfiguration;
+ try {
+ contextConfiguration = serializer.fromString(contextConfigurationString, clrClassHierarchy);
+ servicetConfiguration = serializer.fromString(serviceConfigurationString, clrClassHierarchy);
+ } catch (final Exception e) {
+ final String message = "Unable to de-serialize CLR context or service configurations using class hierarchy.";
+ LOG.log(Level.SEVERE, message, e);
+ throw new RuntimeException(message, e);
+ }
+ jallocatedEvaluator.submitContextAndService(contextConfiguration, servicetConfiguration);
+ }
+
+ public void submitContextAndServiceAndTaskString(
+ final String contextConfigurationString,
+ final String serviceConfigurationString,
+ final String taskConfigurationString) {
+ if (contextConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty contextConfigurationString provided.");
+ }
+ if (serviceConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty serviceConfigurationString provided.");
+ }
+ if (taskConfigurationString.isEmpty()) {
+ throw new RuntimeException("empty taskConfigurationString provided.");
+ }
+ Configuration contextConfiguration;
+ Configuration servicetConfiguration;
+ Configuration taskConfiguration;
+ try {
+ contextConfiguration = serializer.fromString(contextConfigurationString, clrClassHierarchy);
+ servicetConfiguration = serializer.fromString(serviceConfigurationString, clrClassHierarchy);
+ taskConfiguration = serializer.fromString(taskConfigurationString, clrClassHierarchy);
+ } catch (final Exception e) {
+ final String message = "Unable to de-serialize CLR context or service or task configurations using class hierarchy.";
+ LOG.log(Level.SEVERE, message, e);
+ throw new RuntimeException(message, e);
+ }
+ jallocatedEvaluator.submitContextAndServiceAndTask(contextConfiguration, servicetConfiguration, taskConfiguration);
+ }
+
+ public String getEvaluatorDescriptorSring() {
+ String descriptorString = Utilities.getEvaluatorDescriptorString(jallocatedEvaluator.getEvaluatorDescriptor());
+ LOG.log(Level.INFO, "allocated evaluator - serialized evaluator descriptor: " + descriptorString);
+ return descriptorString;
+ }
+
+ @Override
+ public void close() {
+ jallocatedEvaluator.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ClosedContextBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ClosedContextBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ClosedContextBridge.java
new file mode 100644
index 0000000..62f9ce7
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ClosedContextBridge.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.driver.context.ClosedContext;
+import org.apache.reef.driver.evaluator.EvaluatorDescriptor;
+import org.apache.reef.util.Optional;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class ClosedContextBridge extends NativeBridge implements ClosedContext {
+
+ private static final Logger LOG = Logger.getLogger(ClosedContextBridge.class.getName());
+
+ private final ClosedContext jcloseContext;
+ private final ActiveContextBridge parentContext;
+ private final String contextId;
+ private final String evaluatorId;
+ private final EvaluatorDescriptor evaluatorDescriptor;
+
+ public ClosedContextBridge(final ClosedContext closedContext) {
+ jcloseContext = closedContext;
+ parentContext = new ActiveContextBridge(closedContext.getParentContext());
+ contextId = closedContext.getId();
+ evaluatorId = closedContext.getEvaluatorId();
+ evaluatorDescriptor = closedContext.getEvaluatorDescriptor();
+ }
+
+ @Override
+ public String getId() {
+ return contextId;
+ }
+
+ @Override
+ public String getEvaluatorId() {
+ return evaluatorId;
+ }
+
+ @Override
+ public Optional<String> getParentId() {
+ return Optional.of(parentContext.getId());
+ }
+
+ @Override
+ public EvaluatorDescriptor getEvaluatorDescriptor() {
+ return evaluatorDescriptor;
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ public String getEvaluatorDescriptorSring() {
+ String descriptorString = Utilities.getEvaluatorDescriptorString(evaluatorDescriptor);
+ LOG.log(Level.INFO, "Closed Context - serialized evaluator descriptor: " + descriptorString);
+ return descriptorString;
+ }
+
+ @Override
+ public ActiveContext getParentContext() {
+ return jcloseContext.getParentContext();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedEvaluatorBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedEvaluatorBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedEvaluatorBridge.java
new file mode 100644
index 0000000..0e300fd
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedEvaluatorBridge.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.evaluator.CompletedEvaluator;
+import org.apache.reef.io.naming.Identifiable;
+
+public class CompletedEvaluatorBridge extends NativeBridge implements Identifiable {
+
+ private final CompletedEvaluator jcompletedEvaluator;
+
+ private final String evaluatorId;
+
+ public CompletedEvaluatorBridge(CompletedEvaluator completedEvaluator) {
+ jcompletedEvaluator = completedEvaluator;
+ evaluatorId = completedEvaluator.getId();
+ }
+
+ @Override
+ public String getId() {
+ return evaluatorId;
+ }
+
+ @Override
+ public void close() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedTaskBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedTaskBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedTaskBridge.java
new file mode 100644
index 0000000..c95ca14
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/CompletedTaskBridge.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.task.CompletedTask;
+
+public class CompletedTaskBridge extends NativeBridge {
+
+ private CompletedTask jcompletedTask;
+
+ private String taskId;
+
+ private ActiveContextBridge jactiveContext;
+
+ public CompletedTaskBridge(CompletedTask completedTask) {
+ jcompletedTask = completedTask;
+ taskId = completedTask.getId();
+ jactiveContext = new ActiveContextBridge(completedTask.getActiveContext());
+ }
+
+ @Override
+ public void close() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ContextMessageBridge.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ContextMessageBridge.java b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ContextMessageBridge.java
new file mode 100644
index 0000000..eca4ba8
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-java/src/main/java/org/apache/reef/javabridge/ContextMessageBridge.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.javabridge;
+
+import org.apache.reef.driver.context.ContextMessage;
+
+public class ContextMessageBridge extends NativeBridge implements ContextMessage {
+
+ private ContextMessage jcontextMessage;
+ private String contextMessageId;
+ private String messageSourceId;
+ private byte[] message;
+
+ public ContextMessageBridge(ContextMessage contextMessage) {
+ jcontextMessage = contextMessage;
+ contextMessageId = contextMessage.getId();
+ messageSourceId = contextMessage.getMessageSourceID();
+ message = contextMessage.get();
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ @Override
+ public byte[] get() {
+ return message;
+ }
+
+ @Override
+ public String getId() {
+ return contextMessageId;
+ }
+
+ @Override
+ public String getMessageSourceID() {
+ return messageSourceId;
+ }
+}