ImmutableSet<ResourceInfo> getResources() { ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder(); for (Entry<ClassLoader, String> entry : resources.entries()) { builder.add(ResourceInfo.of(entry.getValue(), entry.getKey())); } return builder.build(); }
ImmutableSet<ResourceInfo> getResources() { ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder(); for (Entry<ClassLoader, String> entry : resources.entries()) { builder.add(ResourceInfo.of(entry.getValue(), entry.getKey())); } return builder.build(); }
ImmutableSet<ResourceInfo> getResources() { ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder(); for (Entry<ClassLoader, String> entry : resources.entries()) { builder.add(ResourceInfo.of(entry.getValue(), entry.getKey())); } return builder.build(); }
private void scanDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet<File> ancestors) throws IOException { File canonical = directory.getCanonicalFile(); if (ancestors.contains(canonical)) { // A cycle in the filesystem, for example due to a symbolic link. return; } File[] files = directory.listFiles(); if (files == null) { logger.warning("Cannot read directory " + directory); // IO error, just skip the directory return; } ImmutableSet<File> newAncestors = ImmutableSet.<File>builder() .addAll(ancestors) .add(canonical) .build(); for (File f : files) { String name = f.getName(); if (f.isDirectory()) { scanDirectory(f, classloader, packagePrefix + name + "/", newAncestors); } else { String resourceName = packagePrefix + name; if (!resourceName.equals(JarFile.MANIFEST_NAME)) { resources.add(ResourceInfo.of(resourceName, classloader)); } } } }
private void scanDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet<File> ancestors) throws IOException { File canonical = directory.getCanonicalFile(); if (ancestors.contains(canonical)) { // A cycle in the filesystem, for example due to a symbolic link. return; } File[] files = directory.listFiles(); if (files == null) { logger.warning("Cannot read directory " + directory); // IO error, just skip the directory return; } ImmutableSet<File> newAncestors = ImmutableSet.<File>builder() .addAll(ancestors) .add(canonical) .build(); for (File f : files) { String name = f.getName(); if (f.isDirectory()) { scanDirectory(f, classloader, packagePrefix + name + "/", newAncestors); } else { String resourceName = packagePrefix + name; if (!resourceName.equals(JarFile.MANIFEST_NAME)) { resources.add(ResourceInfo.of(resourceName, classloader)); } } } }
private void scanDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet<File> ancestors) throws IOException { File canonical = directory.getCanonicalFile(); if (ancestors.contains(canonical)) { // A cycle in the filesystem, for example due to a symbolic link. return; } File[] files = directory.listFiles(); if (files == null) { logger.warning("Cannot read directory " + directory); // IO error, just skip the directory return; } ImmutableSet<File> newAncestors = ImmutableSet.<File>builder() .addAll(ancestors) .add(canonical) .build(); for (File f : files) { String name = f.getName(); if (f.isDirectory()) { scanDirectory(f, classloader, packagePrefix + name + "/", newAncestors); } else { String resourceName = packagePrefix + name; if (!resourceName.equals(JarFile.MANIFEST_NAME)) { resources.add(ResourceInfo.of(resourceName, classloader)); } } } }
private void scanDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet<File> ancestors) throws IOException { File canonical = directory.getCanonicalFile(); if (ancestors.contains(canonical)) { // A cycle in the filesystem, for example due to a symbolic link. return; } File[] files = directory.listFiles(); if (files == null) { logger.warning("Cannot read directory " + directory); // IO error, just skip the directory return; } ImmutableSet<File> newAncestors = ImmutableSet.<File>builder() .addAll(ancestors) .add(canonical) .build(); for (File f : files) { String name = f.getName(); if (f.isDirectory()) { scanDirectory(f, classloader, packagePrefix + name + "/", newAncestors); } else { String resourceName = packagePrefix + name; if (!resourceName.equals(JarFile.MANIFEST_NAME)) { resources.add(ResourceInfo.of(resourceName, classloader)); } } } }
private static void browseJar( File file, ClassLoader classloader, ImmutableSet.Builder<ResourceInfo> resources) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { browse(uri, classloader, resources); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().startsWith("META-INF/")) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet<File> ancestors) throws IOException { File canonical = directory.getCanonicalFile(); if (ancestors.contains(canonical)) { // A cycle in the filesystem, for example due to a symbolic link. return; } File[] files = directory.listFiles(); if (files == null) { logger.warning("Cannot read directory " + directory); // IO error, just skip the directory return; } ImmutableSet<File> newAncestors = ImmutableSet.<File>builder() .addAll(ancestors) .add(canonical) .build(); for (File f : files) { String name = f.getName(); if (f.isDirectory()) { scanDirectory(f, classloader, packagePrefix + name + "/", newAncestors); } else { String resourceName = packagePrefix + name; if (!resourceName.equals(JarFile.MANIFEST_NAME)) { resources.add(ResourceInfo.of(resourceName, classloader)); } } } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private void scanJar(File file, ClassLoader classloader) throws IOException { JarFile jarFile; try { jarFile = new JarFile(file); } catch (IOException e) { // Not a jar file return; } try { for (URI uri : getClassPathFromManifest(file, jarFile.getManifest())) { scan(uri, classloader); } Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.add(ResourceInfo.of(entry.getName(), classloader)); } } finally { try { jarFile.close(); } catch (IOException ignored) {} } }
private static void browseDirectory( File directory, ClassLoader classloader, String packagePrefix, ImmutableSet.Builder<ResourceInfo> resources) { for (File f : directory.listFiles()) { String name = f.getName(); if (f.isDirectory()) { browseDirectory(f, classloader, packagePrefix + name + "/", resources); } else { String resourceName = packagePrefix + name; resources.add(ResourceInfo.of(resourceName, classloader)); } } }
ImmutableSet<ResourceInfo> getResources() { ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder(); for (Entry<ClassLoader, String> entry : resources.entries()) { builder.add(ResourceInfo.of(entry.getValue(), entry.getKey())); } return builder.build(); }
ImmutableSet<ResourceInfo> getResources() { ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder(); for (Entry<ClassLoader, String> entry : resources.entries()) { builder.add(ResourceInfo.of(entry.getValue(), entry.getKey())); } return builder.build(); }
private static ResourceInfo resourceInfo(Class<?> cls) { String resource = cls.getName().replace('.', '/') + ".class"; ClassLoader loader = cls.getClassLoader(); return ResourceInfo.of(resource, loader); }
private static ResourceInfo resourceInfo(Class<?> cls) { String resource = cls.getName().replace('.', '/') + ".class"; ClassLoader loader = cls.getClassLoader(); return ResourceInfo.of(resource, loader); }