Search in sources :

Example 1 with MockComponentLogger

use of org.apache.nifi.mock.MockComponentLogger in project nifi by apache.

the class ProcessorInitializer method teardown.

@Override
public void teardown(ConfigurableComponent component) {
    Processor processor = (Processor) component;
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        final ComponentLog logger = new MockComponentLogger();
        final MockProcessContext context = new MockProcessContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, processor, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) Processor(org.apache.nifi.processor.Processor) MockComponentLogger(org.apache.nifi.mock.MockComponentLogger) ComponentLog(org.apache.nifi.logging.ComponentLog) MockProcessContext(org.apache.nifi.mock.MockProcessContext)

Example 2 with MockComponentLogger

use of org.apache.nifi.mock.MockComponentLogger in project nifi-minifi by apache.

the class ProcessorInitializer method teardown.

@Override
public void teardown(ConfigurableComponent component) {
    Processor processor = (Processor) component;
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        final ComponentLog logger = new MockComponentLogger();
        final MockProcessContext context = new MockProcessContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, processor, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) Processor(org.apache.nifi.processor.Processor) MockComponentLogger(org.apache.nifi.mock.MockComponentLogger) ComponentLog(org.apache.nifi.logging.ComponentLog) MockProcessContext(org.apache.nifi.mock.MockProcessContext)

Example 3 with MockComponentLogger

use of org.apache.nifi.mock.MockComponentLogger in project nifi-minifi by apache.

the class ReportingTaskingInitializer method teardown.

@Override
public void teardown(ConfigurableComponent component) {
    ReportingTask reportingTask = (ReportingTask) component;
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        final MockConfigurationContext context = new MockConfigurationContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, reportingTask, new MockComponentLogger(), context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) MockConfigurationContext(org.apache.nifi.mock.MockConfigurationContext) MockComponentLogger(org.apache.nifi.mock.MockComponentLogger) ReportingTask(org.apache.nifi.reporting.ReportingTask)

Example 4 with MockComponentLogger

use of org.apache.nifi.mock.MockComponentLogger in project nifi-minifi by apache.

the class ControllerServiceInitializer method teardown.

@Override
public void teardown(ConfigurableComponent component) {
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        ControllerService controllerService = (ControllerService) component;
        final ComponentLog logger = new MockComponentLogger();
        final MockConfigurationContext context = new MockConfigurationContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, controllerService, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) MockConfigurationContext(org.apache.nifi.mock.MockConfigurationContext) MockComponentLogger(org.apache.nifi.mock.MockComponentLogger) ControllerService(org.apache.nifi.controller.ControllerService) ComponentLog(org.apache.nifi.logging.ComponentLog)

Example 5 with MockComponentLogger

use of org.apache.nifi.mock.MockComponentLogger in project nifi by apache.

the class ControllerServiceInitializer method teardown.

@Override
public void teardown(ConfigurableComponent component) {
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        ControllerService controllerService = (ControllerService) component;
        final ComponentLog logger = new MockComponentLogger();
        final MockConfigurationContext context = new MockConfigurationContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, controllerService, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) MockConfigurationContext(org.apache.nifi.mock.MockConfigurationContext) MockComponentLogger(org.apache.nifi.mock.MockComponentLogger) ControllerService(org.apache.nifi.controller.ControllerService) ComponentLog(org.apache.nifi.logging.ComponentLog)

Aggregations

MockComponentLogger (org.apache.nifi.mock.MockComponentLogger)6 NarCloseable (org.apache.nifi.nar.NarCloseable)6 ComponentLog (org.apache.nifi.logging.ComponentLog)4 MockConfigurationContext (org.apache.nifi.mock.MockConfigurationContext)4 ControllerService (org.apache.nifi.controller.ControllerService)2 MockProcessContext (org.apache.nifi.mock.MockProcessContext)2 Processor (org.apache.nifi.processor.Processor)2 ReportingTask (org.apache.nifi.reporting.ReportingTask)2