/** adds the given URL as something this classloader will load * (however no scanning is done). * <p> * the DTO will _not_ be updated. */ public void addToClasspath(ClassLoader loader) { classloader.addFirst(loader); }
/** creates default instance, with classloaders of Object and AggregateClassLoader */ public static AggregateClassLoader newInstanceWithDefaultLoaders() { AggregateClassLoader cl = new AggregateClassLoader(); cl.addFirst(AggregateClassLoader.class.getClassLoader()); // whichever classloader loaded this jar. cl.addFirst(Object.class.getClassLoader()); // bootstrap loader. return cl; } /** creates default instance, with no classloaders (assuming this instance will itself be nested,
protected synchronized void loadRecursiveClassLoader() { if (recursiveClassLoader!=null) return; AggregateClassLoader cl = AggregateClassLoader.newInstanceWithNoLoaders(); cl.addFirst(childrenClassLoader); ClassLoader local = getLocalClassLoader(); if (local != null) cl.addFirst(local); if (parent == null) { // we are root. include the mgmt base classloader and/or standard class loaders ClassLoader base = mgmt != null ? ((ManagementContextInternal)mgmt).getBaseClassLoader() : null; if (base != null) cl.addFirst(base); else { cl.addFirst(getClass().getClassLoader()); cl.addFirst(Object.class.getClassLoader()); } } recursiveClassLoader = cl; }
protected synchronized void loadLocalClassLoader() { if (classloaderLoaded) return; if (urls==null) return; classloader.addFirst(new UrlClassLoader(urls)); classloaderLoaded = true; return; }
CatalogDo loadCatalog(CatalogDto child, boolean failOnLoadError) { CatalogDo childL = new CatalogDo(child); childrenCatalogs.add(childL); childL.load(mgmt, this, failOnLoadError); childrenClassLoader.addFirst(childL.getRecursiveClassLoader()); clearCache(false); return childL; }
private synchronized void loadManualAdditionsCatalog() { if (manualAdditionsCatalog!=null) return; CatalogDto manualAdditionsCatalogDto = CatalogDto.newNamedInstance( "Manual Catalog Additions", "User-additions to the catalog while Brooklyn is running, " + "created "+Time.makeDateString(), "manual-additions"); CatalogDo manualAdditionsCatalog = catalog.addCatalog(manualAdditionsCatalogDto); if (manualAdditionsCatalog==null) { // not hard to support, but slightly messy -- probably have to use ID's to retrieve the loaded instance // for now block once, then retry log.warn("Blocking until catalog is loaded before changing it"); boolean loaded = blockIfNotLoaded(Duration.TEN_SECONDS); if (!loaded) log.warn("Catalog still not loaded after delay; subsequent operations may fail"); manualAdditionsCatalog = catalog.addCatalog(manualAdditionsCatalogDto); if (manualAdditionsCatalog==null) { throw new UnsupportedOperationException("Catalogs cannot be added until the base catalog is loaded, and catalog is taking a while to load!"); } } log.debug("Creating manual additions catalog for "+mgmt+": "+manualAdditionsCatalog); manualAdditionsClasses = new LoadedClassLoader(); ((AggregateClassLoader)manualAdditionsCatalog.classpath.getLocalClassLoader()).addFirst(manualAdditionsClasses); // expose when we're all done this.manualAdditionsCatalog = manualAdditionsCatalog; }