/** * Returns a set of {@link ResourceInfo} required for the specified {@link Class} using the specified * {@link ClassLoader}. Does not trace dependencies of the specified class. * * @param classLoader the {@link ClassLoader} to use to return the set of {@link ResourceInfo} for the specified * {@link Class} * @param cls the {@link Class} for which to return the set of {@link ResourceInfo} * @return the set of {@link ResourceInfo} required for the specified {@link Class} using the specified * {@link ClassLoader} */ public static Set<ClassPath.ResourceInfo> getClassPathResources(ClassLoader classLoader, Class<?> cls) throws IOException { return getClassPath(classLoader, cls).getResources(); }
/** * Returns a set of {@link ResourceInfo} required for the specified {@link Class} using the specified * {@link ClassLoader}. Does not trace dependencies of the specified class. * * @param classLoader the {@link ClassLoader} to use to return the set of {@link ResourceInfo} for the specified * {@link Class} * @param cls the {@link Class} for which to return the set of {@link ResourceInfo} * @return the set of {@link ResourceInfo} required for the specified {@link Class} using the specified * {@link ClassLoader} */ public static Set<ClassPath.ResourceInfo> getClassPathResources(ClassLoader classLoader, Class<?> cls) throws IOException { return getClassPath(classLoader, cls).getResources(); }
/** * Returns the base set of resources needed to load the specified {@link Class} using the * specified {@link ClassLoader}. Also traces and includes the dependencies for the specified class. * * @param classLoader the {@link ClassLoader} to use to generate the set of resources * @param classz the {@link Class} to generate the set of resources for * @return the set of resources needed to load the specified {@link Class} using the specified {@link ClassLoader} * @throws IOException */ public static Set<String> getResourcesWithDependencies(ClassLoader classLoader, Class<?> classz) throws IOException { ClassPath classPath = getClassPath(classLoader, classz); // Add everything in the classpath as visible resources Set<String> result = Sets.newHashSet(Iterables.transform(classPath.getResources(), RESOURCE_INFO_TO_RESOURCE_NAME)); // Trace dependencies for all classes in the classpath findClassDependencies( classLoader, Iterables.transform(classPath.getAllClasses(), CLASS_INFO_TO_CLASS_NAME), result); return result; }
/** * Returns the base set of resources needed to load the specified {@link Class} using the * specified {@link ClassLoader}. Also traces and includes the dependencies for the specified class. * * @param classLoader the {@link ClassLoader} to use to generate the set of resources * @param classz the {@link Class} to generate the set of resources for * @return the set of resources needed to load the specified {@link Class} using the specified {@link ClassLoader} * @throws IOException */ public static Set<String> getResourcesWithDependencies(ClassLoader classLoader, Class<?> classz) throws IOException { ClassPath classPath = getClassPath(classLoader, classz); // Add everything in the classpath as visible resources Set<String> result = Sets.newHashSet(Iterables.transform(classPath.getResources(), RESOURCE_INFO_TO_RESOURCE_NAME)); // Trace dependencies for all classes in the classpath findClassDependencies( classLoader, Iterables.transform(classPath.getAllClasses(), CLASS_INFO_TO_CLASS_NAME), result); return result; }