private Index tryLoadIndex(URL indexUrl) { if (indexUrl == null) { return null; } try (InputStream in = indexUrl.openStream()) { return new IndexReader(in).read(); } catch (Exception e) { WeldLogger.DEPLOYMENT_LOGGER.cannotLoadAnnotationIndexOfExternalBeanArchive(indexUrl); return null; } }
private void dumpIndex(File source) throws IOException { FileInputStream input = new FileInputStream(source); IndexReader reader = new IndexReader(input); long start = System.currentTimeMillis(); Index index = reader.read(); long end = System.currentTimeMillis() - start; index.printAnnotations(); index.printSubclasses(); System.out.printf("\nRead %s in %.04f seconds\n", source.getName(), end / 1000.0); }
private static IndexView createOrLoadIndex(File indexFile, Supplier<IndexView> indexCreator) { if (indexFile != null) { if (!indexFile.getParentFile().exists()) { indexFile.getParentFile().mkdirs(); } if (!indexFile.exists()) { return indexCreator.get(); } else { try { return new IndexReader(new FileInputStream(indexFile)).read(); } catch (IOException e) { log.error("Failed to read index file '" + indexFile + "'. Creating new index file.", e); if (indexFile.delete()) { return createOrLoadIndex(indexFile, indexCreator); } else { log.error("Failed to read index file '" + indexFile); } } } } return null; }
private void resolveBuildTimeIndex(Module module, List<Index> indexes) { try { Enumeration<URL> indexFiles = module.getClassLoader().findResources(BUILD_TIME_INDEX_NAME, false); while (indexFiles.hasMoreElements()) { URL next = indexFiles.nextElement(); //System.out.println("Found : "+ next); InputStream input = next.openStream(); IndexReader reader = new IndexReader(input); Index index = reader.read(); try { indexes.add(index); } finally { input.close(); } } } catch (IOException e) { e.printStackTrace(); } }
public static CompositeIndex buildCompositeIndex(Module module) { try { final Enumeration<URL> resources = module.getClassLoader().getResources(INDEX_LOCATION); if (!resources.hasMoreElements()) { return null; } final Set<Index> indexes = new HashSet<Index>(); while (resources.hasMoreElements()) { final URL url = resources.nextElement(); InputStream stream = url.openStream(); try { IndexReader reader = new IndexReader(stream); indexes.add(reader.read()); } finally { stream.close(); } } return new CompositeIndex(indexes); } catch (IOException e) { throw new RuntimeException(e); } }
public static CompositeIndex buildCompositeIndex(Module module) { try { final Enumeration<URL> resources = module.getClassLoader().getResources(INDEX_LOCATION); if (!resources.hasMoreElements()) { return null; } final Set<Index> indexes = new HashSet<Index>(); while (resources.hasMoreElements()) { final URL url = resources.nextElement(); InputStream stream = url.openStream(); try { IndexReader reader = new IndexReader(stream); indexes.add(reader.read()); } finally { stream.close(); } } return new CompositeIndex(indexes); } catch (IOException e) { throw new RuntimeException(e); } }
public static CompositeIndex buildCompositeIndex(Module module) { try { final Enumeration<URL> resources = module.getClassLoader().getResources(INDEX_LOCATION); if (!resources.hasMoreElements()) { return null; } final Set<Index> indexes = new HashSet<Index>(); while (resources.hasMoreElements()) { final URL url = resources.nextElement(); InputStream stream = url.openStream(); try { IndexReader reader = new IndexReader(stream); indexes.add(reader.read()); } finally { stream.close(); } } return new CompositeIndex(indexes); } catch (IOException e) { throw new RuntimeException(e); } }
public static CompositeIndex buildCompositeIndex(Module module) { try { final Enumeration<URL> resources = module.getClassLoader().getResources(INDEX_LOCATION); if (!resources.hasMoreElements()) { return null; } final Set<Index> indexes = new HashSet<Index>(); while (resources.hasMoreElements()) { final URL url = resources.nextElement(); InputStream stream = url.openStream(); try { IndexReader reader = new IndexReader(stream); indexes.add(reader.read()); } finally { stream.close(); } } return new CompositeIndex(indexes); } catch (IOException e) { throw new RuntimeException(e); } }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
private Index getIndex(final File beanArchiveFile) { Preconditions.checkArgumentNotNull(beanArchiveFile, "beanArchiveFile"); logger.debugv("Try to get Jandex index for: {0}", beanArchiveFile); Index index = null; try (ZipFile zip = new ZipFile(beanArchiveFile)) { // Open the bean archive and try to find the index file ZipEntry entry = zip.getEntry(JANDEX_INDEX_NAME); if (entry != null) { index = new IndexReader(zip.getInputStream(entry)).read(); } } catch (IllegalArgumentException e) { CommonLogger.LOG.warnv("Jandex index is not valid: {0}", beanArchiveFile); } catch (UnsupportedVersion e) { CommonLogger.LOG.warnv("Version of Jandex index is not supported: {0}", beanArchiveFile); } catch (IOException e) { CommonLogger.LOG.warnv("Cannot get Jandex index from: {0}", beanArchiveFile); CommonLogger.LOG.catchingDebug(e); } logger.debugv("Jandex index {0}found: {1}", index == null ? "NOT " : "", beanArchiveFile); return index; }
@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; } }
@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; } }
try (InputStream indexStream = indexNode.getAsset().openStream()) { LOGGER.debugv("Loading attached index from archive: {0}", archive.getName()); indexes.add(new IndexReader(indexStream).read());
try (InputStream indexStream = indexNode.getAsset().openStream()) { LOGGER.debugv("Loading attached index from archive: {0}", archive.getName()); indexes.add(new IndexReader(indexStream).read());