org.apache.nifi.controller.ControllerServiceLookup Java Examples

The following examples show how to use org.apache.nifi.controller.ControllerServiceLookup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatelessPropertyValue.java    From nifi with Apache License 2.0 5 votes vote down vote up
private StatelessPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final PropertyDescriptor propertyDescriptor, final boolean alreadyEvaluated,
                               final ParameterLookup parameterLookup, final VariableRegistry variableRegistry) {
    this.stdPropValue = new StandardPropertyValue(rawValue, serviceLookup, parameterLookup, variableRegistry);
    this.rawValue = rawValue;
    this.serviceLookup = (StatelessControllerServiceLookup) serviceLookup;
    this.expectExpressions = propertyDescriptor == null ? null : propertyDescriptor.isExpressionLanguageSupported();
    this.expressionLanguageScope = propertyDescriptor == null ? null : propertyDescriptor.getExpressionLanguageScope();
    this.propertyDescriptor = propertyDescriptor;
    this.expressionsEvaluated = alreadyEvaluated;
    this.variableRegistry = variableRegistry;
    this.parameterLookup = parameterLookup;
}
 
Example #2
Source File: MockConfigurationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
public MockConfigurationContext(final ControllerService service,
        final Map<PropertyDescriptor, String> properties,
        final ControllerServiceLookup serviceLookup,
        final VariableRegistry variableRegistry) {
    this.service = service;
    this.properties = properties;
    this.serviceLookup = serviceLookup;
    this.variableRegistry = variableRegistry;
}
 
Example #3
Source File: MockConfigurationContext.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public MockConfigurationContext(final ControllerService service,
        final Map<PropertyDescriptor, String> properties,
        final ControllerServiceLookup serviceLookup,
        final VariableRegistry variableRegistry) {
    this.service = service;
    this.properties = properties;
    this.serviceLookup = serviceLookup;
    this.variableRegistry = variableRegistry;
}
 
Example #4
Source File: MockPropertyValue.java    From nifi with Apache License 2.0 5 votes vote down vote up
private MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final PropertyDescriptor propertyDescriptor, final boolean alreadyEvaluated,
        final VariableRegistry variableRegistry) {
    this.stdPropValue = new StandardPropertyValue(rawValue, serviceLookup, ParameterLookup.EMPTY, variableRegistry);
    this.rawValue = rawValue;
    this.serviceLookup = (MockControllerServiceLookup) serviceLookup;
    this.expectExpressions = propertyDescriptor == null ? null : propertyDescriptor.isExpressionLanguageSupported();
    this.expressionLanguageScope = propertyDescriptor == null ? null : propertyDescriptor.getExpressionLanguageScope();
    this.propertyDescriptor = propertyDescriptor;
    this.expressionsEvaluated = alreadyEvaluated;
    this.variableRegistry = variableRegistry;
}
 
Example #5
Source File: MockPropertyValue.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final PropertyDescriptor propertyDescriptor, final boolean alreadyEvaluated,
                          final VariableRegistry variableRegistry) {
    this.stdPropValue = new StandardPropertyValue(rawValue, serviceLookup, variableRegistry);

    this.rawValue = rawValue;
    this.serviceLookup = serviceLookup;
    this.expectExpressions = propertyDescriptor == null ? null : propertyDescriptor.isExpressionLanguageSupported();
    this.propertyDescriptor = propertyDescriptor;
    this.expressionsEvaluated = alreadyEvaluated;
    this.variableRegistry = variableRegistry;
}
 
Example #6
Source File: StatelessConfigurationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StatelessConfigurationContext(final ControllerService service,
                                     final Map<PropertyDescriptor, PropertyConfiguration> properties,
                                     final ControllerServiceLookup serviceLookup,
                                     final VariableRegistry variableRegistry,
                                     final ParameterContext parameterLookup) {
    this.service = service;
    this.properties = properties;
    this.serviceLookup = serviceLookup;
    this.variableRegistry = variableRegistry;
    this.parameterContext = parameterLookup;
}
 
Example #7
Source File: StandardConfigurationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StandardConfigurationContext(final ComponentNode component, final ControllerServiceLookup serviceLookup, final String schedulingPeriod,
                                    final VariableRegistry variableRegistry) {
    this.component = component;
    this.serviceLookup = serviceLookup;
    this.schedulingPeriod = schedulingPeriod;
    this.variableRegistry = variableRegistry;

    if (schedulingPeriod == null) {
        schedulingNanos = null;
    } else {
        if (FormatUtils.TIME_DURATION_PATTERN.matcher(schedulingPeriod).matches()) {
            schedulingNanos = FormatUtils.getTimeDuration(schedulingPeriod, TimeUnit.NANOSECONDS);
        } else {
            schedulingNanos = null;
        }
    }

    preparedQueries = new HashMap<>();
    for (final Map.Entry<PropertyDescriptor, String> entry : component.getEffectivePropertyValues().entrySet()) {
        final PropertyDescriptor desc = entry.getKey();
        String value = entry.getValue();
        if (value == null) {
            value = desc.getDefaultValue();
        }

        final PreparedQuery pq = Query.prepare(value);
        preparedQueries.put(desc, pq);
    }
}
 
Example #8
Source File: StatelessPropertyValue.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StatelessPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final ParameterLookup parameterLookup, final VariableRegistry variableRegistry) {
    this(rawValue, serviceLookup, parameterLookup, variableRegistry, null);
}
 
Example #9
Source File: StatelessProcessorInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StatelessProcessorInitializationContext(final String id, final Processor processor, final ControllerServiceLookup controllerServiceLookup) {
    processorId = id;
    logger = new SLF4JComponentLog(processor);
    this.controllerServiceLookup = controllerServiceLookup;
}
 
Example #10
Source File: ComponentFactory.java    From nifi with Apache License 2.0 4 votes vote down vote up
private ControllerService createControllerService(final VersionedControllerService versionedControllerService, final VariableRegistry variableRegistry, final Set<URL> classpathUrls,
                                                  final ControllerServiceLookup serviceLookup, final StateManager stateManager, final ParameterLookup parameterLookup) {

    final String type = versionedControllerService.getType();
    final String identifier = versionedControllerService.getIdentifier();

    final Bundle bundle = getAvailableBundle(versionedControllerService.getBundle(), type);
    if (bundle == null) {
        throw new IllegalStateException("Unable to find bundle for coordinate "
            + versionedControllerService.getBundle().getGroup() + ":"
            + versionedControllerService.getBundle().getArtifact() + ":"
            + versionedControllerService.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 ControllerService service = (ControllerService) extensionInstance;
        final ControllerServiceInitializationContext initializationContext = new StatelessControllerServiceInitializationContext(identifier, service, serviceLookup, stateManager);
        service.initialize(initializationContext);

        // If no classpath urls were provided, check if we need to add additional classpath URL's based on configured properties.
        if (classpathUrls == null) {
            final Set<URL> additionalClasspathUrls = getAdditionalClasspathResources(service.getPropertyDescriptors(), service.getIdentifier(), versionedControllerService.getProperties(),
                parameterLookup, variableRegistry, componentLog);

            if (!additionalClasspathUrls.isEmpty()) {
                return createControllerService(versionedControllerService, variableRegistry, additionalClasspathUrls, serviceLookup, stateManager, parameterLookup);
            }
        }

        return service;
    } catch (final Exception e) {
        throw new ControllerServiceInstantiationException(type, e);
    } finally {
        if (ctxClassLoader != null) {
            Thread.currentThread().setContextClassLoader(ctxClassLoader);
        }
    }
}
 
Example #11
Source File: ComponentFactory.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ControllerService createControllerService(final VersionedControllerService versionedControllerService, final VariableRegistry variableRegistry,
                                                 final ControllerServiceLookup serviceLookup, final StateManager stateManager, final ParameterLookup parameterLookup) {
    return createControllerService(versionedControllerService, variableRegistry, null, serviceLookup, stateManager, parameterLookup);
}
 
Example #12
Source File: StatelessProcessorInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ControllerServiceLookup getControllerServiceLookup() {
    return controllerServiceLookup;
}
 
Example #13
Source File: StandardProcessorInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return serviceProvider;
}
 
Example #14
Source File: MockProcessContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return this;
}
 
Example #15
Source File: MockControllerServiceInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return this;
}
 
Example #16
Source File: StandardSearchContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StandardSearchContext(final String searchTerm, final ProcessorNode processorNode, final ControllerServiceLookup controllerServiceLookup, VariableRegistry variableRegistry) {
    this.searchTerm = searchTerm;
    this.processorNode = processorNode;
    this.controllerServiceLookup = controllerServiceLookup;
    this.variableRegistry = variableRegistry;
}
 
Example #17
Source File: MockControllerServiceInitializationContext.java    From nifi-minifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new MockControllerServiceLookup();
}
 
Example #18
Source File: StatelessPropertyValue.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StatelessPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final ParameterLookup parameterLookup) {
    this(rawValue, serviceLookup, parameterLookup, VariableRegistry.EMPTY_REGISTRY, null);
}
 
Example #19
Source File: MockPropertyValue.java    From nifi with Apache License 2.0 4 votes vote down vote up
public MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, VariableRegistry variableRegistry, final PropertyDescriptor propertyDescriptor) {
    this(rawValue, serviceLookup, propertyDescriptor, false, variableRegistry);
}
 
Example #20
Source File: MockProcessContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new MockControllerServiceLookup();
}
 
Example #21
Source File: MockPropertyValue.java    From nifi with Apache License 2.0 4 votes vote down vote up
public MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup) {
    this(rawValue, serviceLookup, VariableRegistry.EMPTY_REGISTRY, null);
}
 
Example #22
Source File: MockReportingContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return this;
}
 
Example #23
Source File: MockValidationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return this;
}
 
Example #24
Source File: DocumentationReportingInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new EmptyControllerServiceLookup();
}
 
Example #25
Source File: StandardReportingContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return this;
}
 
Example #26
Source File: DocumentationProcessorInitializationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new EmptyControllerServiceLookup();
}
 
Example #27
Source File: MockReportingInitializationContext.java    From nifi-minifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new MockControllerServiceLookup();
}
 
Example #28
Source File: ConnectableProcessContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return null;
}
 
Example #29
Source File: MockProcessContext.java    From nifi-minifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new MockControllerServiceLookup();
}
 
Example #30
Source File: MockProcessorInitializationContext.java    From nifi-minifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceLookup getControllerServiceLookup() {
    return new MockControllerServiceLookup();
}