if (metadata == null && !index.getAllKnownImplementors(EXTENSION_NAME).isEmpty()) { return null;
private static Set<ClassInfo> getAllImplementors ( Index i, DotName root ) { return i.getAllKnownImplementors(root); }
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
protected List<Class<? extends ServerConfiguration>> findServerConfigurationImpls(Module module) throws ModuleLoadException, IOException, NoSuchFieldException, IllegalAccessException { Indexer indexer = new Indexer(); Iterator<Resource> resources = module.iterateResources(PathFilters.acceptAll()); while (resources.hasNext()) { Resource each = resources.next(); if (each.getName().endsWith(".class")) { try { ClassInfo clsInfo = indexer.index(each.openStream()); } catch (IOException e) { //System.err.println("error: " + each.getName() + ": " + e.getMessage()); } } } Index index = indexer.complete(); Set<ClassInfo> infos = index.getAllKnownImplementors(DotName.createSimple(ServerConfiguration.class.getName())); List<Class<? extends ServerConfiguration>> impls = new ArrayList<>(); for (ClassInfo info : infos) { try { Class<? extends ServerConfiguration> cls = (Class<? extends ServerConfiguration>) module.getClassLoader().loadClass(info.name().toString()); if (!Modifier.isAbstract(cls.getModifiers())) { impls.add(cls); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } return impls; //List<AnnotationInstance> found = index.getAnnotations(DotName.createSimple(Configuration.class.getName())); //return found; }
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
@SuppressWarnings("unchecked") private Set<Class<? extends Fraction>> uninstalledFractionClasses(Set<Type> installedClasses) throws ModuleLoadException, IOException, ClassNotFoundException { Set<String> installedClassNames = installedClasses.stream().map(Type::getTypeName).collect(Collectors.toSet()); List<String> moduleNames = ApplicationEnvironment.get().bootstrapModules(); ClassLoader cl = Module.getBootModuleLoader().loadModule("swarm.container").getClassLoader(); Set<Class<? extends Fraction>> fractionClasses = new HashSet<>(); for (String moduleName : moduleNames) { Module module = Module.getBootModuleLoader().loadModule(moduleName); InputStream indexStream = module.getClassLoader().getResourceAsStream("META-INF/jandex.idx"); if (indexStream != null) { IndexReader reader = new IndexReader(indexStream); Index index = reader.read(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(Fraction.class.getName())); for (ClassInfo impl : impls) { if (!installedClassNames.contains(impl.name().toString())) { Class<? extends Fraction> fractionClass = (Class<? extends Fraction>) cl.loadClass(impl.name().toString()); fractionClasses.add(fractionClass); } } } } return fractionClasses; } }
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
@SuppressWarnings("unchecked") private Set<Class<? extends Fraction>> uninstalledFractionClasses(Set<Type> installedClasses) throws ModuleLoadException, IOException, ClassNotFoundException { Set<String> installedClassNames = installedClasses.stream().map(Type::getTypeName).collect(Collectors.toSet()); List<String> moduleNames = ApplicationEnvironment.get().bootstrapModules(); ClassLoader cl = Module.getBootModuleLoader().loadModule("swarm.container").getClassLoader(); Set<Class<? extends Fraction>> fractionClasses = new HashSet<>(); for (String moduleName : moduleNames) { Module module = Module.getBootModuleLoader().loadModule(moduleName); InputStream indexStream = module.getClassLoader().getResourceAsStream("META-INF/jandex.idx"); if (indexStream != null) { IndexReader reader = new IndexReader(indexStream); Index index = reader.read(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(Fraction.class.getName())); for (ClassInfo impl : impls) { if (!installedClassNames.contains(impl.name().toString())) { Class<? extends Fraction> fractionClass = (Class<? extends Fraction>) cl.loadClass(impl.name().toString()); fractionClasses.add(fractionClass); } } } } return fractionClasses; } }
@SuppressWarnings("unchecked") private Set<Class<? extends Fraction>> uninstalledFractionClasses(Set<Type> installedClasses) throws ModuleLoadException, IOException, ClassNotFoundException { Set<String> installedClassNames = installedClasses.stream().map(Type::getTypeName).collect(Collectors.toSet()); List<String> moduleNames = ApplicationEnvironment.get().bootstrapModules(); ClassLoader cl = Module.getBootModuleLoader().loadModule("swarm.container").getClassLoader(); Set<Class<? extends Fraction>> fractionClasses = new HashSet<>(); for (String moduleName : moduleNames) { Module module = Module.getBootModuleLoader().loadModule(moduleName); InputStream indexStream = module.getClassLoader().getResourceAsStream("META-INF/jandex.idx"); if (indexStream != null) { IndexReader reader = new IndexReader(indexStream); Index index = reader.read(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(Fraction.class.getName())); for (ClassInfo impl : impls) { if (!installedClassNames.contains(impl.name().toString())) { Class<? extends Fraction> fractionClass = (Class<? extends Fraction>) cl.loadClass(impl.name().toString()); fractionClasses.add(fractionClass); } } } } return fractionClasses; } }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
clazzes = this.input.getIndex().getAllKnownImplementors(DotName.createSimple(Serializable.class.getName()));