mirror of https://github.com/apache/nifi.git
NIFI-632 using NarThreadContextClassLoader when generating documentation
This commit is contained in:
parent
6f36c7939b
commit
4074ec3785
|
@ -26,6 +26,10 @@
|
||||||
<groupId>org.apache.nifi</groupId>
|
<groupId>org.apache.nifi</groupId>
|
||||||
<artifactId>nifi-api</artifactId>
|
<artifactId>nifi-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.nifi</groupId>
|
||||||
|
<artifactId>nifi-framework-core-api</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.nifi</groupId>
|
<groupId>org.apache.nifi</groupId>
|
||||||
<artifactId>nifi-properties</artifactId>
|
<artifactId>nifi-properties</artifactId>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.nifi.documentation.init.ControllerServiceInitializer;
|
||||||
import org.apache.nifi.documentation.init.ProcessorInitializer;
|
import org.apache.nifi.documentation.init.ProcessorInitializer;
|
||||||
import org.apache.nifi.documentation.init.ReportingTaskingInitializer;
|
import org.apache.nifi.documentation.init.ReportingTaskingInitializer;
|
||||||
import org.apache.nifi.nar.ExtensionManager;
|
import org.apache.nifi.nar.ExtensionManager;
|
||||||
|
import org.apache.nifi.nar.NarThreadContextClassLoader;
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.reporting.ReportingTask;
|
import org.apache.nifi.reporting.ReportingTask;
|
||||||
|
@ -68,17 +69,25 @@ public class DocGenerator {
|
||||||
logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: "
|
logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: "
|
||||||
+ explodedNiFiDocsDir);
|
+ explodedNiFiDocsDir);
|
||||||
|
|
||||||
for (final Class<?> extensionClass : extensionClasses) {
|
// save the original class loader and use a NarThreadContextClassLoader
|
||||||
if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) {
|
final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
final Class<? extends ConfigurableComponent> componentClass = extensionClass
|
try {
|
||||||
.asSubclass(ConfigurableComponent.class);
|
Thread.currentThread().setContextClassLoader(NarThreadContextClassLoader.getInstance());
|
||||||
try {
|
|
||||||
logger.debug("Documenting: " + componentClass);
|
for (final Class<?> extensionClass : extensionClasses) {
|
||||||
document(explodedNiFiDocsDir, componentClass);
|
if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) {
|
||||||
} catch (Exception e) {
|
final Class<? extends ConfigurableComponent> componentClass = extensionClass
|
||||||
logger.warn("Unable to document: " + componentClass, e);
|
.asSubclass(ConfigurableComponent.class);
|
||||||
|
try {
|
||||||
|
logger.debug("Documenting: " + componentClass);
|
||||||
|
document(explodedNiFiDocsDir, componentClass);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Unable to document: " + componentClass, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Thread.currentThread().setContextClassLoader(originalClassLoader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue