Java Code Examples for org.apache.nifi.nar.ExtensionManager#getBundles()
The following examples show how to use
org.apache.nifi.nar.ExtensionManager#getBundles() .
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: ComponentDAO.java From nifi with Apache License 2.0 | 6 votes |
protected void verifyCreate(final ExtensionManager extensionManager, final String type, final BundleDTO bundle) { final List<Bundle> bundles = extensionManager.getBundles(type); if (bundle != null) { final BundleCoordinate coordinate = new BundleCoordinate(bundle.getGroup(), bundle.getArtifact(), bundle.getVersion()); if (bundles.stream().filter(b -> b.getBundleDetails().getCoordinate().equals(coordinate)).count() == 0) { throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", coordinate.toString())); } } else { if (bundles.isEmpty()) { throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", type)); } else if (bundles.size() > 1) { throw new IllegalStateException(String.format("Multiple versions of %s exist. Please specify the desired bundle.", type)); } } }
Example 2
Source File: StandardStateManagerProvider.java From nifi with Apache License 2.0 | 6 votes |
private static StateProvider instantiateStateProvider(final ExtensionManager extensionManager, final String type) throws ClassNotFoundException, InstantiationException, IllegalAccessException { final ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader(); try { final List<Bundle> bundles = extensionManager.getBundles(type); if (bundles.size() == 0) { throw new IllegalStateException(String.format("The specified class '%s' is not known to this nifi.", type)); } if (bundles.size() > 1) { throw new IllegalStateException(String.format("Multiple bundles found for the specified class '%s', only one is allowed.", type)); } final Bundle bundle = bundles.get(0); final ClassLoader detectedClassLoaderForType = bundle.getClassLoader(); final Class<?> rawClass = Class.forName(type, true, detectedClassLoaderForType); Thread.currentThread().setContextClassLoader(detectedClassLoaderForType); final Class<? extends StateProvider> mgrClass = rawClass.asSubclass(StateProvider.class); return withNarClassLoader(mgrClass.newInstance()); } finally { if (ctxClassLoader != null) { Thread.currentThread().setContextClassLoader(ctxClassLoader); } } }
Example 3
Source File: BundleUtils.java From nifi with Apache License 2.0 | 5 votes |
private static BundleCoordinate findBundleForType(final ExtensionManager extensionManager, final String type, final BundleCoordinate desiredCoordinate) { final List<Bundle> bundles = extensionManager.getBundles(type); if (bundles.isEmpty()) { throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", type)); } else if (bundles.size() > 1) { if (desiredCoordinate == null) { throw new IllegalStateException(String.format("Multiple versions of %s exist.", type)); } else { throw new IllegalStateException(String.format("Multiple versions of %s exist. No exact match for %s.", type, desiredCoordinate)); } } else { return bundles.get(0).getBundleDetails().getCoordinate(); } }
Example 4
Source File: MiNiFi.java From nifi-minifi with Apache License 2.0 | 4 votes |
protected List<Bundle> getBundles(final String bundleClass) { return ExtensionManager.getBundles(bundleClass); }