MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / onTrigger

Method onTrigger

extensions/jni/ExecuteJavaProcessor.cpp:179–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void ExecuteJavaProcessor::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) {
180
181 assert(context == jpc.context_);
182 auto env = java_servicer_->attach();
183
184 if (ClassRegistrar::getRegistrar().registerClasses(env, java_servicer_, "org/apache/nifi/processor/JniFlowFile", getFlowFileSignatures())) {
185 static auto ffc = java_servicer_->loadClass("org/apache/nifi/processor/JniFlowFile");
186 java_servicer_->putNativeFunctionMapping<JniFlowFile>(env, ffc);
187
188 }
189 if (ClassRegistrar::getRegistrar().registerClasses(env, java_servicer_, "org/apache/nifi/processor/JniInputStream", getInputStreamSignatures())) {
190 static auto jin = java_servicer_->loadClass("org/apache/nifi/processor/JniInputStream");
191 java_servicer_->putNativeFunctionMapping<JniInputStream>(env, jin);
192 }
193 static auto sessioncls = java_servicer_->loadClass("org/apache/nifi/processor/JniProcessSession");
194
195 if (ClassRegistrar::getRegistrar().registerClasses(env, java_servicer_, "org/apache/nifi/processor/JniProcessSession", getProcessSessionSignatures())) {
196 java_servicer_->putNativeFunctionMapping<minifi::jni::JniSession>(env, sessioncls);
197 }
198 ClassRegistrar::getRegistrar().registerClasses(env, java_servicer_, "org/apache/nifi/processor/JniProcessSessionFactory", getProcessSessionFactorySignatures());
199
200 static auto sessionFactoryCls = java_servicer_->loadClass("org/apache/nifi/processor/JniProcessSessionFactory");
201
202 try {
203 // it is possible that java classes will maintain a reference to the session factory, so we cannot remove the global references
204 // in this function.
205 jobject java_process_session_factory = nullptr;
206
207 JniSessionFactory *jniSessionFactory = getFactory(sessionFactory);
208
209 if (!jniSessionFactory) {
210 java_process_session_factory = sessionFactoryCls.newInstance(env);
211 jniSessionFactory = setFactory(sessionFactory, java_process_session_factory);
212 java_servicer_->putNativeFunctionMapping<JniSessionFactory>(env, sessionFactoryCls);
213 java_servicer_->setReference<JniSessionFactory>(env, java_process_session_factory, jniSessionFactory);
214 } else {
215 java_process_session_factory = jniSessionFactory->getJavaReference();
216 }
217 current_processor_class.callVoidMethod(env, clazzInstance, "onTrigger", "(Lorg/apache/nifi/processor/ProcessContext;Lorg/apache/nifi/processor/ProcessSessionFactory;)V", context_instance_,
218 java_process_session_factory);
219 } catch (const JavaException &je) {
220 // clear the java exception so we don't continually wrap it
221 env->ExceptionClear();
222 logger_->log_error(" Java Exception occurred during onTrigger, reason: %s", je.what());
223 } catch (const std::exception &e) {
224 // clear the java exception so we don't continually wrap it
225 env->ExceptionClear();
226 logger_->log_error(" Exception occurred during onTrigger, reason: %s", e.what());
227 }
228}
229
230void ExecuteJavaProcessor::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
231 // do nothing.

Callers

nothing calls this directly

Calls 8

registerClassesMethod · 0.80
loadClassMethod · 0.80
getJavaReferenceMethod · 0.80
callVoidMethodMethod · 0.80
log_errorMethod · 0.80
attachMethod · 0.45
newInstanceMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected