@Override public InstanceClassLoader removeInstanceClassLoader(final String instanceIdentifier) { if (instanceIdentifier == null) { return null; } final InstanceClassLoader classLoader = instanceClassloaderLookup.remove(instanceIdentifier); closeURLClassLoader(instanceIdentifier, classLoader); return classLoader; }
@Override public void discoverExtensions(final Bundle systemBundle, final Set<Bundle> narBundles) { // load the system bundle first so that any extensions found in JARs directly in lib will be registered as // being from the system bundle and not from all the other NARs loadExtensions(systemBundle); bundleCoordinateBundleLookup.put(systemBundle.getBundleDetails().getCoordinate(), systemBundle); discoverExtensions(narBundles); }
@Override public ConfigurableComponent getTempComponent(final String classType, final BundleCoordinate bundleCoordinate) { if (classType == null) { throw new IllegalArgumentException("Class type cannot be null"); } if (bundleCoordinate == null) { throw new IllegalArgumentException("Bundle Coordinate cannot be null"); } return tempComponentLookup.get(getClassBundleKey(classType, bundleCoordinate)); }
initializeTempComponent(configurableComponent); final String cacheKey = getClassBundleKey(o.getClass().getCanonicalName(), bundle.getBundleDetails().getCoordinate()); tempComponentLookup.put(cacheKey, (ConfigurableComponent)o); if (isControllerService && !checkControllerServiceEligibility(extensionType)) { registerExtension = false; logger.error(String.format( if (canReferenceControllerService && !checkControllerServiceReferenceEligibility((ConfigurableComponent) o, bundle.getClassLoader())) { registerExtension = false; logger.error(String.format( registerServiceClass(o.getClass(), classNameBundleLookup, bundleCoordinateClassesLookup, bundle, entry.getValue());
final String key = getClassBundleKey(classType, bundle.getBundleDetails().getCoordinate()); final ConfigurableComponent component = getTempComponent(classType, bundle.getBundleDetails().getCoordinate()); final Set<BundleCoordinate> reachableApiBundles = findReachableApiBundles(component);
if (!multipleVersionsAllowed(type)) { throw new IllegalStateException("Attempt was made to load " + className + " from " + bundle.getBundleDetails().getCoordinate().getCoordinate() final String cacheKey = getClassBundleKey(className, bundleCoordinate); requiresInstanceClassLoading.put(cacheKey, type);
@Override public void discoverExtensions(final Set<Bundle> narBundles) { // get the current context class loader ClassLoader currentContextClassLoader = Thread.currentThread().getContextClassLoader(); // consider each nar class loader for (final Bundle bundle : narBundles) { // Must set the context class loader to the nar classloader itself // so that static initialization techniques that depend on the context class loader will work properly final ClassLoader ncl = bundle.getClassLoader(); Thread.currentThread().setContextClassLoader(ncl); loadExtensions(bundle); // Create a look-up from coordinate to bundle bundleCoordinateBundleLookup.put(bundle.getBundleDetails().getCoordinate(), bundle); } // restore the current context class loader if appropriate if (currentContextClassLoader != null) { Thread.currentThread().setContextClassLoader(currentContextClassLoader); } }
try { final ExtensionDiscoveringManager extensionManager = new StandardExtensionDiscoveringManager(); extensionManager.discoverExtensions(systemBundle, bundles); extensionManager.logClassLoaderMapping();