com.google.common.reflect.ClassPath.getClassPathEntries()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中com.google.common.reflect.ClassPath.getClassPathEntries()方法的一些代码示例,展示了ClassPath.getClassPathEntries()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPath.getClassPathEntries()方法的具体详情如下:
包路径:com.google.common.reflect.ClassPath
类名称:ClassPath
方法名:getClassPathEntries

ClassPath.getClassPathEntries介绍

暂无

代码示例

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: com.google.guava/guava-jdk5

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: Nextdoor/bender

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@VisibleForTesting static ImmutableMap<URI, ClassLoader> getClassPathEntries(
  ClassLoader classloader) {
 LinkedHashMap<URI, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 if (classloader instanceof URLClassLoader) {
  URLClassLoader urlClassLoader = (URLClassLoader) classloader;
  for (URL entry : urlClassLoader.getURLs()) {
   URI uri;
   try {
    uri = entry.toURI();
   } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
   }
   if (!entries.containsKey(uri)) {
    entries.put(uri, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 Scanner scanner = new Scanner();
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  scanner.scan(entry.getKey(), entry.getValue());
 }
 return new ClassPath(scanner.getResources());
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Returns a {@code ClassPath} representing all classes and resources loadable from {@code
 * classloader} and its parent class loaders.
 *
 * <p>Currently only {@link URLClassLoader} and only {@code file://} urls are supported.
 *
 * @throws IOException if the attempt to read class path resources (jar files or directories)
 *         failed.
 */
public static ClassPath from(ClassLoader classloader) throws IOException {
 ImmutableSortedSet.Builder<ResourceInfo> resources =
   new ImmutableSortedSet.Builder<ResourceInfo>(Ordering.usingToString());
 for (Map.Entry<URI, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
  browse(entry.getKey(), entry.getValue(), resources);
 }
 return new ClassPath(resources.build());
}

相关文章