@Override public Object run() { for (ClassLoaderHook hook : hooks) { hook.classLoaderCreated(cl); } return null; }
static ModuleClassLoader createClassLoaderPrivledged(ClassLoader parent, EquinoxConfiguration configuration, BundleLoader delegate, Generation generation, List<ClassLoaderHook> hooks) { // allow hooks to extend the ModuleClassLoader implementation for (ClassLoaderHook hook : hooks) { ModuleClassLoader hookClassLoader = hook.createClassLoader(parent, configuration, delegate, generation); if (hookClassLoader != null) { // first one to return non-null wins. return hookClassLoader; } } // just use the default one return new EquinoxClassLoader(parent, configuration, delegate, generation); }
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) { // allow hooks to determine the parent class loader for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) { ClassLoader parent = hook.getModuleClassLoaderParent(configuration); if (parent != null) { // first one to return non-null wins. return parent; } } // DEFAULT behavior: // check property for specified parent // check the osgi defined property first String type = configuration.getConfiguration(Constants.FRAMEWORK_BUNDLE_PARENT); if (type == null) { type = configuration.getConfiguration(EquinoxConfiguration.PROP_PARENT_CLASSLOADER, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); } if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); return cl == null ? BOOT_CLASSLOADER : cl; } if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equalsIgnoreCase(type)) return ClassLoader.getSystemClassLoader(); if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equalsIgnoreCase(type)) { ClassLoader appCL = ClassLoader.getSystemClassLoader(); if (appCL != null) return appCL.getParent(); } return BOOT_CLASSLOADER; }
/** * Finds a local resource by searching the ClasspathEntry objects of the classpath manager. * This method will first call all the configured class loading hooks * {@link ClassLoaderHook#preFindLocalResource(String, ClasspathManager)} methods. Then it * will search for the resource. Finally it will call all the configured class loading hooks * {@link ClassLoaderHook#postFindLocalResource(String, URL, ClasspathManager)} methods. * @param resource the requested resource name. * @return the requested resource URL or null if the resource does not exist */ public URL findLocalResource(String resource) { List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks(); for (ClassLoaderHook hook : hooks) { hook.preFindLocalResource(resource, this); } URL result = null; try { result = findLocalResourceImpl(resource, -1); return result; } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalResource(resource, result, this); } } }
switch (type) { case PRE_CLASS : result = (E) hook.preFindClass(name, getModuleClassLoader()); break; case POST_CLASS : result = (E) hook.postFindClass(name, getModuleClassLoader()); break; case PRE_RESOURCE : result = (E) hook.preFindResource(name, getModuleClassLoader()); break; case POST_RESOURCE : result = (E) hook.postFindResource(name, getModuleClassLoader()); break; case PRE_RESOURCES : result = (E) hook.preFindResources(name, getModuleClassLoader()); break; case POST_RESOURCES : result = (E) hook.postFindResources(name, getModuleClassLoader()); break;
for (ClassLoaderHook hook : hooks) { try { result = hook.preFindLibrary(libname, classloader); if (result != null) { return result; result = hook.postFindLibrary(libname, classloader); if (result != null) { return result;
try { for (ClassLoaderHook hook : hooks) { hook.preFindLocalClass(classname, this); } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalClass(classname, result, this);
private String findLibrary0(String libname) { String path = null; List<ClassLoaderHook> hooks = generation.getBundleInfo().getStorage().getConfiguration().getHookRegistry().getClassLoaderHooks(); for (ClassLoaderHook hook : hooks) { path = hook.findLocalLibrary(generation, libname); if (path != null) { return path; } } String mappedName = System.mapLibraryName(libname); String[] altMappedNames = mapLibraryNames(mappedName); // first check Bundle-NativeCode header path = findBundleNativeCode(libname, mappedName, altMappedNames); // next check eclipse specific support return path != null ? path : findEclipseNativeCode(libname, mappedName, altMappedNames); }
/** * Finds all the ClasspathEntry objects for the requested classpath. This method will first call all * the configured class loading hooks {@link ClassLoaderHook#addClassPathEntry(ArrayList, String, ClasspathManager, Generation)} * methods. This allows class loading hooks to add additional ClasspathEntry objects to the result for the * requested classpath. Then the local host classpath entries and attached fragment classpath entries are * searched. * @param result a list of ClasspathEntry objects. This list is used to add new ClasspathEntry objects to. * @param cp the requested classpath. * @param hostloader the host classpath manager for the classpath * @param sourceGeneration the source generation to search for the classpath */ private void findClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostloader, Generation sourceGeneration) { List<ClassLoaderHook> loaderHooks = hookRegistry.getClassLoaderHooks(); boolean hookAdded = false; for (ClassLoaderHook hook : loaderHooks) { hookAdded |= hook.addClassPathEntry(result, cp, hostloader, sourceGeneration); } if (!addClassPathEntry(result, cp, hostloader, sourceGeneration) && !hookAdded) { BundleException be = new BundleException(NLS.bind(Msg.BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION, cp, sourceGeneration.getRevision().toString()), BundleException.MANIFEST_ERROR); sourceGeneration.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.INFO, sourceGeneration.getRevision().getRevisions().getModule(), be); } }
switch (type) { case PRE_CLASS : result = (E) hook.preFindClass(name, getModuleClassLoader()); break; case POST_CLASS : result = (E) hook.postFindClass(name, getModuleClassLoader()); break; case PRE_RESOURCE : result = (E) hook.preFindResource(name, getModuleClassLoader()); break; case POST_RESOURCE : result = (E) hook.postFindResource(name, getModuleClassLoader()); break; case PRE_RESOURCES : result = (E) hook.preFindResources(name, getModuleClassLoader()); break; case POST_RESOURCES : result = (E) hook.postFindResources(name, getModuleClassLoader()); break;
/** * Finds a local resource by searching the ClasspathEntry objects of the classpath manager. * This method will first call all the configured class loading hooks * {@link ClassLoaderHook#preFindLocalResource(String, ClasspathManager)} methods. Then it * will search for the resource. Finally it will call all the configured class loading hooks * {@link ClassLoaderHook#postFindLocalResource(String, URL, ClasspathManager)} methods. * @param resource the requested resource name. * @return the requested resource URL or null if the resource does not exist */ public URL findLocalResource(String resource) { List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks(); for (ClassLoaderHook hook : hooks) { hook.preFindLocalResource(resource, this); } URL result = null; try { result = findLocalResourceImpl(resource, -1); return result; } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalResource(resource, result, this); } } }
for (ClassLoaderHook hook : hooks) { try { result = hook.preFindLibrary(libname, classloader); if (result != null) { return result; result = hook.postFindLibrary(libname, classloader); if (result != null) { return result;
try { for (ClassLoaderHook hook : hooks) { hook.preFindLocalClass(classname, this); } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalClass(classname, result, this);
private String findLibrary0(String libname) { String path = null; List<ClassLoaderHook> hooks = generation.getBundleInfo().getStorage().getConfiguration().getHookRegistry().getClassLoaderHooks(); for (ClassLoaderHook hook : hooks) { path = hook.findLocalLibrary(generation, libname); if (path != null) { return path; } } String mappedName = System.mapLibraryName(libname); String[] altMappedNames = mapLibraryNames(mappedName); // first check Bundle-NativeCode header path = findBundleNativeCode(libname, mappedName, altMappedNames); // next check eclipse specific support return path != null ? path : findEclipseNativeCode(libname, mappedName, altMappedNames); }
/** * Finds all the ClasspathEntry objects for the requested classpath. This method will first call all * the configured class loading hooks {@link ClassLoaderHook#addClassPathEntry(ArrayList, String, ClasspathManager, Generation)} * methods. This allows class loading hooks to add additional ClasspathEntry objects to the result for the * requested classpath. Then the local host classpath entries and attached fragment classpath entries are * searched. * @param result a list of ClasspathEntry objects. This list is used to add new ClasspathEntry objects to. * @param cp the requested classpath. * @param hostloader the host classpath manager for the classpath * @param sourceGeneration the source generation to search for the classpath */ private void findClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostloader, Generation sourceGeneration) { List<ClassLoaderHook> loaderHooks = hookRegistry.getClassLoaderHooks(); boolean hookAdded = false; for (ClassLoaderHook hook : loaderHooks) { hookAdded |= hook.addClassPathEntry(result, cp, hostloader, sourceGeneration); } if (!addClassPathEntry(result, cp, hostloader, sourceGeneration) && !hookAdded) { BundleException be = new BundleException(NLS.bind(Msg.BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION, cp, sourceGeneration.getRevision().toString()), BundleException.MANIFEST_ERROR); sourceGeneration.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.INFO, sourceGeneration.getRevision().getRevisions().getModule(), be); } }
switch (type) { case PRE_CLASS : result = (E) hook.preFindClass(name, getModuleClassLoader()); break; case POST_CLASS : result = (E) hook.postFindClass(name, getModuleClassLoader()); break; case PRE_RESOURCE : result = (E) hook.preFindResource(name, getModuleClassLoader()); break; case POST_RESOURCE : result = (E) hook.postFindResource(name, getModuleClassLoader()); break; case PRE_RESOURCES : result = (E) hook.preFindResources(name, getModuleClassLoader()); break; case POST_RESOURCES : result = (E) hook.postFindResources(name, getModuleClassLoader()); break;
/** * Finds a local resource by searching the ClasspathEntry objects of the classpath manager. * This method will first call all the configured class loading stats hooks * {@link ClassLoaderHook#preFindLocalResource(String, ClasspathManager)} methods. Then it * will search for the resource. Finally it will call all the configured class loading stats hooks * {@link ClassLoaderHook#postFindLocalResource(String, URL, ClasspathManager)} methods. * @param resource the requested resource name. * @return the requested resource URL or null if the resource does not exist */ public URL findLocalResource(String resource) { List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks(); for (ClassLoaderHook hook : hooks) { hook.preFindLocalResource(resource, this); } URL result = null; try { result = findLocalResourceImpl(resource, -1); return result; } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalResource(resource, result, this); } } }
for (ClassLoaderHook hook : hooks) { try { result = hook.preFindLibrary(libname, classloader); if (result != null) { return result; result = hook.postFindLibrary(libname, classloader); if (result != null) { return result;
try { for (ClassLoaderHook hook : hooks) { hook.preFindLocalClass(classname, this); } finally { for (ClassLoaderHook hook : hooks) { hook.postFindLocalClass(classname, result, this);
static ModuleClassLoader createClassLoaderPrivledged(ClassLoader parent, EquinoxConfiguration configuration, BundleLoader delegate, Generation generation, List<ClassLoaderHook> hooks) { // allow hooks to extend the ModuleClassLoader implementation for (ClassLoaderHook hook : hooks) { ModuleClassLoader hookClassLoader = hook.createClassLoader(parent, configuration, delegate, generation); if (hookClassLoader != null) { // first one to return non-null wins. return hookClassLoader; } } // just use the default one return new EquinoxClassLoader(parent, configuration, delegate, generation); }