Hello,

I'm working to see what we can share, but for a start, here is how we
handle the delegating controller service:

package com.civitaslearning.nifi.service.impl;


import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.dbcp.DBCPService;

import java.util.Collections;
import java.util.List;
import java.util.UUID;

public class DelegatingDBCPServiceImpl extends
AbstractControllerService implements DelegatingDBCPService {

  private static final List<PropertyDescriptor> properties =
Collections.emptyList();

  @Override
  public DBCPService getDBCPService(UUID uuid) {
    DBCPService dbcpService =
        (DBCPService)
getControllerServiceLookup().getControllerService(uuid.toString());

    if (dbcpService == null) {
      throw new NullPointerException("Couldn't find DBCP service with
ID " + uuid);
    }

    return dbcpService;
  }

  @Override
  public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    return properties;
  }
}


>From there, we took existing nifi processor code such as ExecuteSQL and
modified it to require a reference to a delegating service rather than a
DBCP service and added another property to specify which flow file
attribute has the id of the dbcp service that should be used, similar to:

final DelegatingDBCPService delegatingDBCPService =
context.getProperty(DELEGATING_DBCP_SERVICE).asControllerService(DelegatingDBCPService.class);
final UUID dbcpServiceId =
UUID.fromString(context.getProperty(DBCP_SERVICE_ATTRIBUTE).evaluateAttributeExpressions(fileToProcess).getValue());
final DBCPService dbcpService =
delegatingDBCPService.getDBCPService(dbcpServiceId);

thanks

On Thu, Apr 26, 2018 at 4:07 AM, RP <rishabprasad...@gmail.com> wrote:

> Hi Charlie,
>
> Thanks for the reply. It seems that you already have a solution to my
> problem. If possible, can you please share you code for the custom
> controller service and the custom processor?
>
>
>
> -----
> RP
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>

Reply via email to