Search in sources :

Example 1 with ControllerServiceAPI

use of org.apache.nifi.registry.flow.ControllerServiceAPI in project nifi by apache.

the class NiFiRegistryFlowMapper method mapControllerServiceApis.

private List<ControllerServiceAPI> mapControllerServiceApis(final ControllerServiceNode service) {
    final Class<?> serviceClass = service.getControllerServiceImplementation().getClass();
    final Set<Class<?>> serviceApiClasses = new HashSet<>();
    // get all of it's interfaces to determine the controller service api's it implements
    final List<Class<?>> interfaces = ClassUtils.getAllInterfaces(serviceClass);
    for (final Class<?> i : interfaces) {
        // add all controller services that's not ControllerService itself
        if (ControllerService.class.isAssignableFrom(i) && !ControllerService.class.equals(i)) {
            serviceApiClasses.add(i);
        }
    }
    final List<ControllerServiceAPI> serviceApis = new ArrayList<>();
    for (final Class<?> serviceApiClass : serviceApiClasses) {
        final BundleCoordinate bundleCoordinate = ExtensionManager.getBundle(serviceApiClass.getClassLoader()).getBundleDetails().getCoordinate();
        final ControllerServiceAPI serviceApi = new ControllerServiceAPI();
        serviceApi.setType(serviceApiClass.getName());
        serviceApi.setBundle(mapBundle(bundleCoordinate));
        serviceApis.add(serviceApi);
    }
    return serviceApis;
}
Also used : ControllerServiceAPI(org.apache.nifi.registry.flow.ControllerServiceAPI) ArrayList(java.util.ArrayList) ControllerService(org.apache.nifi.controller.ControllerService) VersionedControllerService(org.apache.nifi.registry.flow.VersionedControllerService) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)1 ControllerService (org.apache.nifi.controller.ControllerService)1 ControllerServiceAPI (org.apache.nifi.registry.flow.ControllerServiceAPI)1 VersionedControllerService (org.apache.nifi.registry.flow.VersionedControllerService)1