public TopologyComponentBundleResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, EnvironmentService environmentService, Subject subject) { this.authorizer = authorizer; this.catalogService = catalogService; this.environmentService = environmentService; this.subject = subject; this.hintProviderProxyUtil = new ProxyUtil<>(ComponentBundleHintProvider.class); }
public NotificationServiceImpl(Map<String, Object> config, NotificationStore store) { LOG.info("Initializing NotificationServiceImpl with config {}, notification store {}", config, store); this.notificationStore = Optional.ofNullable(store); if(config.get(QUEUEHANDLER_THREADS) != null) { this.queueHandler = new NotificationQueueHandler(((Number)config.get(QUEUEHANDLER_THREADS)).intValue()); } else { this.queueHandler = new NotificationQueueHandler(); } this.notifierProxyUtil = new ProxyUtil<>(Notifier.class); }
public static Collection<Class<?>> loadAllClassesFromJar(final File jarFile, final Class<?> superTypeClass) throws IOException { List<Class<?>> classes = JarReader.findConcreteSubtypesOfClass(jarFile, superTypeClass); final ProxyUtil<?> proxyUtil = new ProxyUtil<>(superTypeClass); return Collections2.filter(classes, new Predicate<Class<?>>() { @Override public boolean apply(@Nullable Class<?> s) { try { proxyUtil.loadClassFromJar(jarFile.getAbsolutePath(), s.getName()); return true; } catch (Throwable ex) { LOG.warn("class {} is concrete subtype of {}, but can't be initialized due to exception:", s, superTypeClass, ex); return false; } } }); }
FluxComponent getFluxComponent(StreamlineComponent streamlineComponent) { ProxyUtil<FluxComponent> proxyUtil = new ProxyUtil<>(FluxComponent.class); try { FluxComponent fluxComponent = proxyUtil.loadClassFromLibDirectory(extraJarsLocation, streamlineComponent.getTransformationClass()); return fluxComponent; } catch (ClassNotFoundException | MalformedURLException | InstantiationException | IllegalAccessException e) { LOG.error("Error while creating flux component", e); throw new RuntimeException(e); } } }
/** * Creates an instance of the given class which is loaded from the given jar or current class loader if {@code jarId} is null. * * @param <T> type of the object to be created * @param jarId id of the jar resource * @param fqcn FullyQualifiedClassName of the object to be created * @param klass Class instance of the object to be created * @return instance of the given class loaded from the given jar or current class loader if {@code jarId} is null. */ protected <T> T getInstance(Long jarId, String fqcn, Class<T> klass) { T instance = null; if (fqcn != null) { try { if (jarId != null) { ProxyUtil<T> proxyUtil = new ProxyUtil<>(klass, AbstractSplitJoinActionRuntime.class.getClassLoader()); String jarPath = getJarPathFor(jarId); instance = proxyUtil.loadClassFromJar(jarPath, fqcn); } else { // FQCN is given but no jarId then that class is assumed to be accessible from current class loader. instance = (T) Class.forName(fqcn, true, Thread.currentThread().getContextClassLoader()).newInstance(); } } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e.getMessage(), e); } } return instance; } }
private void loadTransformationClassForBundle (TopologyComponentBundle topologyComponentBundle, java.io.File bundleJar) { if (topologyComponentBundle.getStreamingEngine().equals(TopologyLayoutConstants.STORM_STREAMING_ENGINE)) { if (topologyComponentBundle.getBuiltin()) { // no transformation class validations for top level topology type if (topologyComponentBundle.getType() == TopologyComponentBundle.TopologyComponentType.TOPOLOGY) { return; } try { FluxComponent fluxComponent = (FluxComponent) Class.forName(topologyComponentBundle.getTransformationClass()).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOG.debug("Got exception", e); throw new RuntimeException("Check transformationClass property. Cannot load builtin transformation class " + topologyComponentBundle .getTransformationClass()); } } else { ProxyUtil<FluxComponent> fluxComponentProxyUtil = new ProxyUtil<FluxComponent>(FluxComponent.class); try { fluxComponentProxyUtil.loadClassFromJar(bundleJar.getAbsolutePath(), topologyComponentBundle.getTransformationClass()); } catch (IOException | ClassNotFoundException | IllegalAccessException | InstantiationException ex) { LOG.debug("Got exception", ex); throw new RuntimeException("Cannot load transformation class " + topologyComponentBundle.getTransformationClass() + " from bundle Jar: " + bundleJar.getAbsolutePath()); } } } }