You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by se...@apache.org on 2015/01/31 00:51:39 UTC
[7/8] incubator-reef git commit: [REEF-116] Moving bridge code to
proper folder structure
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
new file mode 100644
index 0000000..6dee54f
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
@@ -0,0 +1,96 @@
+/**
+ * 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 Org {
+ namespace Apache {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+ FailedContextClr2Java::FailedContextClr2Java(JNIEnv *env, jobject jobjectFailedContext) {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::FailedContextClr2Java");
+
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedContext = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedContext));
+ jclass jclassFailedContext = env->GetObjectClass (_jobjectFailedContext);
+
+ jfieldID jidContextId = env->GetFieldID(jclassFailedContext, "contextId", "Ljava/lang/String;");
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassFailedContext, "evaluatorId", "Ljava/lang/String;");
+ jfieldID jidParentId = env->GetFieldID(jclassFailedContext, "parentContextId", "Ljava/lang/String;");
+
+ _jstringContextId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidContextId)));
+ _jstringEvaluatorId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidEvaluatorId)));
+ _jstringParentContextId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidParentId)));
+
+ ManagedLog::LOGGER->LogStop("FailedContextClr2Java::FailedContextClr2Java");
+ }
+
+ IActiveContextClr2Java^ FailedContextClr2Java::GetParentContext() {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::GetParentContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedContext = env->GetObjectClass(_jobjectFailedContext);
+ jfieldID jidParentContext = env->GetFieldID(jclassFailedContext, "parentContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectParentContext = env->GetObjectField(_jobjectFailedContext, jidParentContext);
+ ManagedLog::LOGGER->LogStop("FailedContextClr2Java::GetParentContext");
+
+ return gcnew ActiveContextClr2Java(env, jobjectParentContext);
+ }
+
+ String^ FailedContextClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringContextId);
+ }
+
+ String^ FailedContextClr2Java::GetEvaluatorId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetEvaluatorId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringEvaluatorId);
+ }
+
+ String^ FailedContextClr2Java::GetParentId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetParentId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringParentContextId);
+ }
+
+ IEvaluatorDescriptor^ FailedContextClr2Java::GetEvaluatorDescriptor() {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::GetEvaluatorDescriptor");
+ return CommonUtilities::RetrieveEvaluatorDescriptor(_jobjectFailedContext, _jvm);
+ }
+
+ void FailedContextClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedContext);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
new file mode 100644
index 0000000..60e4b1c
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
@@ -0,0 +1,74 @@
+/**
+ * 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 Org {
+ namespace Apache {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ FailedEvaluatorClr2Java::FailedEvaluatorClr2Java(JNIEnv *env, jobject jobjectFailedEvaluator) {
+ ManagedLog::LOGGER->LogStart("FailedEvaluatorClr2Java::FailedEvaluatorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedEvaluator = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedEvaluator));
+
+ jclass jclassFailedEvaluator = env->GetObjectClass(_jobjectFailedEvaluator);
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassFailedEvaluator, "evaluatorId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedEvaluator, jidEvaluatorId)));
+ ManagedLog::LOGGER->LogStop("FailedEvaluatorClr2Java::FailedEvaluatorClr2Java");
+ }
+
+ IEvaluatorRequestorClr2Java^ FailedEvaluatorClr2Java::GetEvaluatorRequestor() {
+ ManagedLog::LOGGER->LogStart("FailedEvaluatorClr2Java::GetEvaluatorRequestor");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedEvaluator = env->GetObjectClass(_jobjectFailedEvaluator);
+ jfieldID jidEvaluatorRequestor = env->GetFieldID(jclassFailedEvaluator, "evaluatorRequestorBridge", "Lorg/apache/reef/javabridge/EvaluatorRequestorBridge;");
+ jobject jobjectEvaluatorRequestor = env->GetObjectField(_jobjectFailedEvaluator, jidEvaluatorRequestor);
+ ManagedLog::LOGGER->LogStop("FailedEvaluatorClr2Java::GetEvaluatorRequestor");
+ return gcnew EvaluatorRequestorClr2Java(env, jobjectEvaluatorRequestor);
+ }
+
+ String^ FailedEvaluatorClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("FailedEvaluatorClr2Java::GetId");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+
+ void FailedEvaluatorClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedEvaluatorClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedEvaluator);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
new file mode 100644
index 0000000..3422c61
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
@@ -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.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Org {
+ namespace Apache {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ FailedTaskClr2Java::FailedTaskClr2Java(JNIEnv *env, jobject jobjectFailedTask) {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::AllocatedEvaluatorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedTask = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedTask));
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::AllocatedEvaluatorClr2Java");
+ }
+
+ IActiveContextClr2Java^ FailedTaskClr2Java::GetActiveContext() {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::GetActiveContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedTask = env->GetObjectClass(_jobjectFailedTask);
+ jfieldID jidActiveContext = env->GetFieldID(jclassFailedTask, "jactiveContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectActiveContext = env->GetObjectField(_jobjectFailedTask, jidActiveContext);
+
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::GetActiveContext");
+ return gcnew ActiveContextClr2Java(env, jobjectActiveContext);
+ }
+
+ String^ FailedTaskClr2Java::GetString() {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::GetString");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedTask = env->GetObjectClass (_jobjectFailedTask);
+ jmethodID jmidGetFailedTaskString = env->GetMethodID(jclassFailedTask, "getFailedTaskString", "()Ljava/lang/String;");
+
+ if (jmidGetFailedTaskString == NULL) {
+ ManagedLog::LOGGER->LogStart("jmidGetFailedTaskString is NULL");
+ return nullptr;
+ }
+ jstring jFailedTaskString = (jstring)env -> CallObjectMethod(
+ _jobjectFailedTask,
+ jmidGetFailedTaskString);
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::GetString");
+ return ManagedStringFromJavaString(env, jFailedTaskString);
+ }
+
+ void FailedTaskClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedTaskClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedTask);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
new file mode 100644
index 0000000..1063243
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
@@ -0,0 +1,137 @@
+/**
+ * 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 Org {
+ namespace Apache {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ HttpServerClr2Java::HttpServerClr2Java(JNIEnv *env, jobject jhttpServerEventBridge) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::HttpServerClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jhttpServerEventBridge = reinterpret_cast<jobject>(env->NewGlobalRef(jhttpServerEventBridge));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::HttpServerClr2Java");
+ }
+
+ String^ HttpServerClr2Java::GetQueryString() {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::GetQueryString");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidgetQueryString = env->GetMethodID(jclasshttpServerEventBridge, "getQueryString", "()Ljava/lang/String;");
+ if (jmidgetQueryString == NULL) {
+ fprintf(stdout, " jmidgetQueryString is NULL\n");
+ fflush (stdout);
+ return nullptr;
+ }
+ jstring jQueryString = (jstring) env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidgetQueryString);
+
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::GetQueryString");
+ return ManagedStringFromJavaString(env, jQueryString);
+ }
+
+ array<byte>^ HttpServerClr2Java::GetQueryRequestData() {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::GetQueryRequestData");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidgetQueryBytes = env->GetMethodID(jclasshttpServerEventBridge, "getQueryRequestData", "()[B");
+
+ if (jmidgetQueryBytes == NULL) {
+ ManagedLog::LOGGER->Log("jmidgetQueryBytes is NULL");
+ return nullptr;
+ }
+ jbyteArray jQueryBytes = (jbyteArray) env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidgetQueryBytes);
+
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::GetQueryRequestData");
+ return ManagedByteArrayFromJavaByteArray(env, jQueryBytes);
+ }
+
+ void HttpServerClr2Java::SetQueryResult(String^ queryResult) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetQueryResult");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetQueryResult = env->GetMethodID(jclasshttpServerEventBridge, "setQueryResult", "(Ljava/lang/String;)V");
+
+ if (jmidsetQueryResult == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetQueryResult is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetQueryResult,
+ JavaStringFromManagedString(env, queryResult));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetQueryResult");
+ }
+
+ void HttpServerClr2Java::SetQueryResponseData(array<byte>^ queryResponseData) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetQueryResponseData");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetQueryResult = env->GetMethodID(jclasshttpServerEventBridge, "setQueryResponseData", "([B)V");
+
+ if (jmidsetQueryResult == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetQueryResult is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetQueryResult,
+ JavaByteArrayFromManagedByteArray(env, queryResponseData));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetQueryResponseData");
+ }
+
+ void HttpServerClr2Java::SetUriSpecification(String^ uriSpecification) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetUriSpecification");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetUriSpecification = env->GetMethodID(jclasshttpServerEventBridge, "setUriSpecification", "(Ljava/lang/String;)V");
+
+ if (jmidsetUriSpecification == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetUriSpecification is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetUriSpecification,
+ JavaStringFromManagedString(env, uriSpecification));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetUriSpecification");
+ }
+
+ void HttpServerClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("HttpServerClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jhttpServerEventBridge);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
new file mode 100644
index 0000000..2e80d71
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
@@ -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.
+ */
+#pragma once
+#define _USING_V110_SDK71_
+
+#pragma warning( push )
+#pragma warning( disable : 4793 )
+#include <jni.h>
+#pragma warning( pop )
+#include "mscoree.h"
+#include "vcclr.h"
+
+using namespace System;
+using namespace System::Reflection;
+using namespace System::Collections::Generic;
+
+public ref class AssemblyUtil {
+ public :
+ static int _asmCount = 0;
+ static Dictionary<String^, System::Reflection::Assembly^>^ asms2 = gcnew Dictionary<String^, Assembly^>();
+ static void Add(Assembly^ myasm);
+ static Assembly^ FindAsm (String^ myasm);
+ static Assembly^ MyResolveEventHandler(Object^ sender, ResolveEventArgs^ args);
+};
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
new file mode 100644
index 0000000..418bd55
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
@@ -0,0 +1,50 @@
+/**
+ * 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 "InteropLogger.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ /// currently not being used
+ InteropLogger::InteropLogger (JNIEnv* env, jobject jobjectInteropLogger) {
+ _env = env;
+ _jobjectInteropLogger = jobjectInteropLogger;
+ _jclassInteropLogger = env->GetObjectClass(jobjectInteropLogger);
+ wchar_t formatBuf[1024];
+ if (NULL == _jclassInteropLogger) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jclassInteropLogger %p\n", _jclassInteropLogger);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+ _jmidLog = env->GetMethodID(_jclassInteropLogger, "Log", "(ILjava/lang/String;)V");
+ if (NULL == _jmidLog) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidLog %p\n", _jmidLog);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ }
+ void InteropLogger::Log(TraceLevel traceLevel, String^ message) {
+ pin_ptr<const wchar_t> wch = PtrToStringChars(message);
+ jstring msg = _env->NewString((const jchar*)wch, message->Length);
+ _env->CallObjectMethod(_jobjectInteropLogger, _jmidLog, (int)traceLevel, msg);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
new file mode 100644
index 0000000..c2a2e80
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
@@ -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 "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#using "clrhandler.dll"
+
+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::Interop;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ public ref class InteropLogger : public ILogger {
+ jobject _jobjectInteropLogger;
+ jclass _jclassInteropLogger;
+ jmethodID _jmidLog;
+ JNIEnv* _env;
+
+ public:
+ InteropLogger (JNIEnv* env, jobject jobjectInteropLogger);
+ virtual void Log(TraceLevel traceLevel, String^ message );
+ };
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
new file mode 100644
index 0000000..821c0d1
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
@@ -0,0 +1,88 @@
+/**
+ * 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 "InteropReturnInfo.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ // currently not being used
+ InteropReturnInfo::InteropReturnInfo (
+ JNIEnv* env,
+ jobject jobjectInteropReturnInfo,
+ ILogger^ logger
+ ) {
+ _env = env;
+ _jobjectInteropReturnInfo = jobjectInteropReturnInfo;
+ jclass thisClass = env->GetObjectClass(jobjectInteropReturnInfo);
+ wchar_t formatBuf[1024];
+
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"zzzzzzz this should be printed by java jmid 00 %p\n", thisClass);
+ logger->Log(TraceLevel::Error, gcnew String(formatBuf));
+ _jmidAddExceptionString = env->GetMethodID(thisClass, "addExceptionString", "(Ljava/lang/String;)V");
+ if (NULL == _jmidAddExceptionString) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidAddExceptionString %p\n", _jmidAddExceptionString);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidHasExceptions = env->GetMethodID(thisClass, "hasExceptions", "()Z");
+ if (NULL == _jmidHasExceptions) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidHasExceptions %p\n", _jmidHasExceptions);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidsetReturnCode = env->GetMethodID(thisClass, "setReturnCode", "(I)V");
+ if (NULL == _jmidsetReturnCode) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidsetReturnCode %p\n", _jmidsetReturnCode);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidgetReturnCode = env->GetMethodID(thisClass, "getReturnCode", "()I");
+ if (NULL == _jmidgetReturnCode) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidgetReturnCode %p\n", _jmidgetReturnCode);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+ }
+
+ void InteropReturnInfo::AddExceptionString(String^ exceptionString) {
+ HasExceptions();
+ pin_ptr<const wchar_t> wch = PtrToStringChars(exceptionString);
+ jstring ret = _env->NewString((const jchar*)wch, exceptionString->Length);
+ _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidAddExceptionString, ret);
+ HasExceptions();
+ }
+
+ Boolean InteropReturnInfo::HasExceptions() {
+ jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidHasExceptions);
+ return ((int)obj) != 0;
+ }
+ void InteropReturnInfo::SetReturnCode(int rc) {
+ _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidsetReturnCode, rc);
+ GetReturnCode();
+ }
+ int InteropReturnInfo::GetReturnCode() {
+ jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidgetReturnCode);
+ return (int)obj;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
new file mode 100644
index 0000000..1278516
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
@@ -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.
+ */
+#include "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#using "clrhandler.dll"
+
+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::Interop;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ public ref class InteropReturnInfo : public IInteropReturnInfo {
+ JNIEnv* _env;
+ jobject _jobjectInteropReturnInfo;
+
+ jmethodID _jmidAddExceptionString;
+ jmethodID _jmidHasExceptions;
+ jmethodID _jmidsetReturnCode;
+ jmethodID _jmidgetReturnCode;
+
+ public:
+ InteropReturnInfo (
+ JNIEnv* env,
+ jobject jobjectInteropReturnInfo,
+ ILogger^ logger
+ );
+ virtual void AddExceptionString(String^ exceptionString);
+ virtual Boolean HasExceptions();
+ virtual void SetReturnCode(int rc);
+ virtual int GetReturnCode();
+ };
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
new file mode 100644
index 0000000..be24f32
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
@@ -0,0 +1,129 @@
+/**
+ * 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 "Clr2JavaImpl.h"
+
+using namespace System::Runtime::InteropServices;
+
+ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>InteropUtil");
+};
+
+const wchar_t* UnicodeCppStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString) {
+ const wchar_t* cppString = NULL;
+ if (NULL != javaString) {
+ cppString = (const wchar_t* )env->GetStringChars( javaString, 0);
+ }
+ return cppString;
+}
+
+void ReleaseUnicodeCppString (
+ JNIEnv* env,
+ jstring javaString,
+ jchar* cppString) {
+ if (NULL != cppString) {
+ env->ReleaseStringChars(javaString, (jchar *)cppString);
+ }
+}
+
+String^ ManagedStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString) {
+ if (javaString != NULL) {
+ int len = env->GetStringLength(javaString);
+ const wchar_t* wcsStr = UnicodeCppStringFromJavaString (env, javaString);
+ String^ managedStr = (NULL == wcsStr || 0 == len) ? nullptr : Marshal::PtrToStringUni((IntPtr)(unsigned short*)wcsStr, len);
+ ReleaseUnicodeCppString (env, javaString, (jchar*)wcsStr);
+ return managedStr;
+ }
+ return nullptr;
+}
+
+jstring JavaStringFromManagedString(
+ JNIEnv *env,
+ String^ managedString) {
+ pin_ptr<const wchar_t> wch = PtrToStringChars(managedString);
+ return env->NewString((const jchar*)wch, managedString->Length);
+}
+
+void HandleClr2JavaError(
+ JNIEnv *env,
+ String^ errorMessage,
+ jobject javaObject) {
+ ManagedLog::LOGGER->LogStart("InteropUtil::HandleClr2JavaError");
+
+ jclass javaClass = env->GetObjectClass (javaObject);
+ jmethodID jmidOnError = env->GetMethodID(javaClass, "onError", "(Ljava/lang/String;)V");
+
+ if (jmidOnError == NULL) {
+ ManagedLog::LOGGER->Log("jmidOnError is NULL");
+ return;
+ }
+ env -> CallObjectMethod(
+ javaObject,
+ jmidOnError,
+ JavaStringFromManagedString(env, errorMessage));
+ ManagedLog::LOGGER->LogStop("InteropUtil::HandleClr2JavaError");
+}
+
+array<byte>^ ManagedByteArrayFromJavaByteArray(
+ JNIEnv *env,
+ jbyteArray javaByteArray) {
+ if (javaByteArray != NULL) {
+ byte* bytes = (byte*)env->GetByteArrayElements (javaByteArray, FALSE);
+ int len = env->GetArrayLength(javaByteArray);
+ array<byte>^ managedByteArray = gcnew array<byte>(len);
+ //System::Array
+ for (int i = 0; i < len; i++) {
+ managedByteArray[i] = bytes[i];
+ }
+ return managedByteArray;
+ }
+ return nullptr;
+}
+
+jbyteArray JavaByteArrayFromManagedByteArray(
+ JNIEnv *env,
+ array<byte>^ managedByteArray) {
+ jbyteArray javaByteArray = env->NewByteArray(managedByteArray->Length);
+ pin_ptr<Byte> p = &managedByteArray[0];
+ env->SetByteArrayRegion(javaByteArray, 0, managedByteArray->Length, (jbyte*) p);
+ return javaByteArray;
+}
+
+jlongArray JavaLongArrayFromManagedLongArray(
+ JNIEnv *env,
+ array<unsigned long long>^ managedLongArray) {
+ jlongArray javaLongArray = env->NewLongArray(managedLongArray->Length);
+ pin_ptr<unsigned long long> p = &managedLongArray[0];
+ env->SetLongArrayRegion(javaLongArray, 0, managedLongArray->Length, (jlong*) p);
+ return javaLongArray;
+}
+
+JNIEnv* RetrieveEnv(JavaVM* jvm) {
+ JNIEnv *env;
+ if (jvm->AttachCurrentThread((void **) &env, NULL) != 0) {
+ ManagedLog::LOGGER->Log("cannot attach jni env to current jvm thread.");
+ throw;
+ }
+ return env;
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
new file mode 100644
index 0000000..2d95bcc
--- /dev/null
+++ b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+#pragma once
+#define _USING_V110_SDK71_
+
+#pragma warning( push )
+#pragma warning( disable : 4793 )
+#include <jni.h>
+#pragma warning( pop )
+#include "mscoree.h"
+#include "vcclr.h"
+
+using namespace System;
+
+const wchar_t* UnicodeCppStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString);
+
+void ReleaseUnicodeCppString (
+ JNIEnv* env,
+ jstring javaString,
+ jchar* cppString);
+
+String^ ManagedStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString);
+
+jstring JavaStringFromManagedString(
+ JNIEnv *env,
+ String^ managedString);
+
+array<byte>^ ManagedByteArrayFromJavaByteArray(
+ JNIEnv *env,
+ jbyteArray javaByteArray);
+
+jbyteArray JavaByteArrayFromManagedByteArray(
+ JNIEnv *env,
+ array<byte>^ managedByteArray);
+
+jlongArray JavaLongArrayFromManagedLongArray(
+ JNIEnv *env,
+ array<unsigned long long>^ managedLongArray);
+
+JNIEnv* RetrieveEnv(JavaVM* jvm);
+
+void HandleClr2JavaError(
+ JNIEnv *env,
+ String^ errorMessage,
+ jobject javaObject);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.cpp
new file mode 100644
index 0000000..b4b79f0
--- /dev/null
+++ b/lang/cpp/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 Org::Apache::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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.h
new file mode 100644
index 0000000..61d9d0a
--- /dev/null
+++ b/lang/cpp/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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.sln
new file mode 100644
index 0000000..d4b2aec
--- /dev/null
+++ b/lang/cpp/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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj
new file mode 100644
index 0000000..d8a889e
--- /dev/null
+++ b/lang/cpp/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>..\..\..\..\..\..\..\java\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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/JavaClrBridge.vcxproj.filters
new file mode 100644
index 0000000..5421846
--- /dev/null
+++ b/lang/cpp/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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ManagedLogger.cpp
new file mode 100644
index 0000000..62e30b3
--- /dev/null
+++ b/lang/cpp/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/22f651f8/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt
----------------------------------------------------------------------
diff --git a/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt b/lang/cpp/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ReadMe.txt
new file mode 100644
index 0000000..4e1b52f
--- /dev/null
+++ b/lang/cpp/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.
+
+/////////////////////////////////////////////////////////////////////////////