public void dumpState(PrintStream writer) { privateLoader.dumpState(writer); writer.println("Nb of classes loaded " + classesLoaded); }
public URL findResource(String name) { return privateLoader.findResource(name); }
/** * Works like {@link #findResource(String)} but only looks at * this module, without delegating to ancestors. */ URL findResourceDirect(String name) { return privateLoader.findResourceDirect(name); }
public URL getResource(String name) { initialize(name); if(name.startsWith(META_INF_SERVICES)) { // punch in. find the service loader from any module String serviceName = name.substring(META_INF_SERVICES.length()); ModulesRegistry reg = module.getRegistry(); for( Module m : reg.getModules() ) { List<URL> list = m.getMetadata().getDescriptors(serviceName); if(!list.isEmpty()) return list.get(0); } // no such resource return super.getResource(name); } else { // normal service look up URL url = super.getResource(name); if(url!=null) return url; // commons-logging looks for a class file resource for providers, // so check for those if(name.endsWith(".class")) { String className = name.replace('/', '.').substring(0, name.length() - 6); ModuleImpl m = module.getRegistry().getProvidingModule(className); if(m!=null) return m.getPrivateClassLoader().getResource(name); } return null; } }
Class<ImportPolicy> importPolicyClass = (Class<ImportPolicy>) getPrivateClassLoader().loadClass(moduleDef.getImportPolicyClassName()); ImportPolicy importPolicy = importPolicyClass.newInstance(); importPolicy.prepare(this); getPrivateClassLoader().addDelegate(m.getClassLoader());
public Module find(Class clazz) { ClassLoader cl = clazz.getClassLoader(); if(cl==null) return null; if (cl instanceof ModuleClassLoader) return ((ModuleClassLoader) cl).getOwner(); return null; }
public void addImport(Module module) { //if (Utils.isLoggable(Level.INFO)) { // Utils.getDefaultLogger().info("For module" + getName() + " adding new dependent " + module.getName()); //} // TODO: this doesn't expose newly added module to // other modules that depend on this module. // but the notion of adding dependencies at runtime is broken anyway. if (!dependencies.contains(module)) { dependencies.add((ModuleImpl)module); getPrivateClassLoader().addDelegate(module.getClassLoader()); } }
/** Creates a new instance of ClassLoaderFacade */ public ClassLoaderFacade(ModuleClassLoader privateLoader) { super(EMPTY_URLS, privateLoader.getParent()); this.privateLoader = privateLoader; }
/** * Tries to find a class from the {@link ModuleClassLoader} that this facade is wrapping, * without doing further delegation to ancestors. */ Class getClass(String name) throws ClassNotFoundException { if (matchExportedPackage(name)) { Class c = privateLoader.findClassDirect(name); classesLoaded++; return c; } return null; }
public ModuleClassLoader run() { return new ModuleClassLoader( ModuleImpl.this, urls, registry.getParentClassLoader()); } });
public Enumeration<URL> findResources(String name) throws IOException { return privateLoader.findResources(name); }
public URL getResource(String name) { initialize(name); if(name.startsWith(META_INF_SERVICES)) { // punch in. find the service loader from any module String serviceName = name.substring(META_INF_SERVICES.length()); ModulesRegistry reg = module.getRegistry(); for( Module m : reg.getModules() ) { List<URL> list = m.getMetadata().getDescriptors(serviceName); if(!list.isEmpty()) return list.get(0); } // no such resource return super.getResource(name); } else { // normal service look up URL url = super.getResource(name); if(url!=null) return url; // commons-logging looks for a class file resource for providers, // so check for those if(name.endsWith(".class")) { String className = name.replace('/', '.').substring(0, name.length() - 6); ModuleImpl m = module.getRegistry().getProvidingModule(className); if(m!=null) return m.getPrivateClassLoader().getResource(name); } return null; } }
Class<ImportPolicy> importPolicyClass = (Class<ImportPolicy>) getPrivateClassLoader().loadClass(moduleDef.getImportPolicyClassName()); ImportPolicy importPolicy = importPolicyClass.newInstance(); importPolicy.prepare(this); getPrivateClassLoader().addDelegate(m.getClassLoader());
public Module find(Class clazz) { ClassLoader cl = clazz.getClassLoader(); if(cl==null) return null; if (cl instanceof ModuleClassLoader) return ((ModuleClassLoader) cl).getOwner(); return null; }
public void addImport(Module module) { //if (Utils.isLoggable(Level.INFO)) { // Utils.getDefaultLogger().info("For module" + getName() + " adding new dependent " + module.getName()); //} // TODO: this doesn't expose newly added module to // other modules that depend on this module. // but the notion of adding dependencies at runtime is broken anyway. if (!dependencies.contains(module)) { dependencies.add((ModuleImpl)module); getPrivateClassLoader().addDelegate(module.getClassLoader()); } }
/** Creates a new instance of ClassLoaderFacade */ public ClassLoaderFacade(ModuleClassLoader privateLoader) { super(EMPTY_URLS, privateLoader.getParent()); this.privateLoader = privateLoader; }
/** * Tries to find a class from the {@link ModuleClassLoader} that this facade is wrapping, * without doing further delegation to ancestors. */ Class getClass(String name) throws ClassNotFoundException { if (matchExportedPackage(name)) { Class c = privateLoader.findClassDirect(name); classesLoaded++; return c; } return null; }
public ModuleClassLoader run() { return new ModuleClassLoader( ModuleImpl.this, urls, registry.getParentClassLoader()); } });