dbkegley commented on a change in pull request #3651: NIFI-6539 Nifi stateless
init from flow xml
URL: https://github.com/apache/nifi/pull/3651#discussion_r314426530
##########
File path:
nifi-stateless/nifi-stateless-core/src/main/java/org/apache/nifi/stateless/core/ComponentFactory.java
##########
@@ -120,6 +124,74 @@ public StatelessProcessorWrapper createProcessor(final
VersionedProcessor versio
}
}
+ public StatelessProcessorWrapper createProcessor(final ProcessorDTO
processorDto, final boolean materializeContent, final
StatelessControllerServiceLookup controllerServiceLookup,
+ final VariableRegistry
variableRegistry, final Set<URL> classpathUrls, final ParameterContext
parameterContext)
+ throws ProcessorInstantiationException {
+
+ final String type = processorDto.getType();
+ final String identifier = processorDto.getId();
+
+ final Bundle bundle = getAvailableBundle(processorDto.getBundle(),
type);
+ if (bundle == null) {
+ throw new IllegalStateException("Unable to find bundle for
coordinate "
+ + processorDto.getBundle().getGroup() + ":"
+ + processorDto.getBundle().getArtifact() + ":"
+ + processorDto.getBundle().getVersion());
+ }
+
+ final ClassLoader ctxClassLoader =
Thread.currentThread().getContextClassLoader();
+ try {
+ final ClassLoader detectedClassLoader =
extensionManager.createInstanceClassLoader(type, identifier, bundle,
+ classpathUrls == null ? Collections.emptySet() :
classpathUrls);
+
+ logger.debug("Setting context class loader to {} (parent = {}) to
create {}", detectedClassLoader, detectedClassLoader.getParent(), type);
+ final Class<?> rawClass = Class.forName(type, true,
detectedClassLoader);
+ Thread.currentThread().setContextClassLoader(detectedClassLoader);
+
+ final Object extensionInstance = rawClass.newInstance();
+ final ComponentLog componentLog = new
SLF4JComponentLog(extensionInstance);
+
+ final Processor processor = (Processor) extensionInstance;
+ final ProcessorInitializationContext initializationContext = new
StatelessProcessorInitializationContext(processor.getIdentifier(), processor,
controllerServiceLookup);
Review comment:
yes, good catch
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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