/** * Creates a new instance for the following set of {@link URL}. * * @param urls the URLs from which to load classes and resources * @param parent the parent classloader for delegation */ public MainClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); this.datasetRewriter = new DatasetClassRewriter(); this.authEnforceRewriter = new AuthEnforceRewriter(); this.resourceLookup = ClassLoaders.createClassResourceLookup(this); this.cache = new HashMap<>(); }
/** * Creates a new instance for the following set of {@link URL}. * * @param urls the URLs from which to load classes and resources * @param parent the parent classloader for delegation */ public MainClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); this.datasetRewriter = new DatasetClassRewriter(); this.authEnforceRewriter = new AuthEnforceRewriter(); this.resourceLookup = ClassLoaders.createClassResourceLookup(this); this.cache = new HashMap<>(); }
/** * Constructs an instance that load classes from the given directory. * <p/> * The URLs for class loading are: * <p/> * <pre> * [dir] * [dir]/*.jar * [dir]/lib/*.jar * </pre> */ public ProgramClassLoader(CConfiguration cConf, File dir, ClassLoader parent) { super(dir, cConf.get(Constants.AppFabric.PROGRAM_EXTRA_CLASSPATH), parent, "lib"); this.dir = dir; this.classResourceLookup = ClassLoaders.createClassResourceLookup(this); this.datasetClassCache = new HashMap<>(); this.datasetClassRewriter = new DatasetClassRewriter(); }
/** * Constructs an instance that load classes from the given directory. * <p/> * The URLs for class loading are: * <p/> * <pre> * [dir] * [dir]/*.jar * [dir]/lib/*.jar * </pre> */ public ProgramClassLoader(CConfiguration cConf, File dir, ClassLoader parent) { super(dir, cConf.get(Constants.AppFabric.PROGRAM_EXTRA_CLASSPATH), parent, "lib"); this.dir = dir; this.classResourceLookup = ClassLoaders.createClassResourceLookup(this); this.datasetClassCache = new HashMap<>(); this.datasetClassRewriter = new DatasetClassRewriter(); }
private List<ClassPath.ClassInfo> getAllHandlerClasses() throws IOException { ClassLoader cl = getClass().getClassLoader(); Map<String, Boolean> cache = new HashMap<>(); Function<String, URL> lookup = ClassLoaders.createClassResourceLookup(cl); ClassPath cp = ClassPath.from(cl); List<ClassPath.ClassInfo> results = new ArrayList<>(); for (ClassPath.ClassInfo info : cp.getAllClasses()) { if (!info.getPackageName().startsWith("co.cask.cdap")) { continue; } if (Classes.isSubTypeOf(info.getName(), HttpHandler.class.getName(), lookup, cache)) { results.add(info); } } return results; }