arpadboda commented on a change in pull request #489: MINIFICPP-740: Add 
ability to run NiFi processors from Java and Python
URL: https://github.com/apache/nifi-minifi-cpp/pull/489#discussion_r259901864
 
 

 ##########
 File path: extensions/jni/ExecuteJavaProcessor.h
 ##########
 @@ -0,0 +1,301 @@
+/**
+ * ExecuteJavaClass class declaration
+ *
+ * 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.
+ */
+#ifndef __EXECUTE_JAVA_CLASS__
+#define __EXECUTE_JAVA_CLASS__
+
+#include <memory>
+
+#include "FlowFileRecord.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Core.h"
+#include "core/Property.h"
+#include "core/Resource.h"
+#include "concurrentqueue.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "jvm/JavaControllerService.h"
+#include "jvm/JniProcessContext.h"
+#include "utils/Id.h"
+#include "jvm/NarClassLoader.h"
+#include "jvm/JniLogger.h"
+#include "jvm/JniReferenceObjects.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace jni {
+namespace processors {
+
+class ClassRegistrar {
+ public:
+  static ClassRegistrar &getRegistrar() {
+    static ClassRegistrar registrar;
+    // do nothing.
+    return registrar;
+  }
+
+  bool registerClasses(JNIEnv *env, 
std::shared_ptr<controllers::JavaControllerService> servicer, const std::string 
&className, JavaSignatures &signatures) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    if (registered_classes_.find(className) == std::end(registered_classes_)) {
+      auto cls = servicer->loadClass(className);
+      cls.registerMethods(env, signatures);
+      registered_classes_.insert(className);
 
 Review comment:
   std::set::insert supports exactly what you need:
   ```
   1-2) Returns a pair consisting of an iterator to the inserted element (or to 
the element that prevented the insertion) 
   and a bool value set to true if the insertion took place.
   ```
   
   So you can avoid using find. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to