@Override public URL getLocalizationEntry(String path) { URL result = null; // #Bug1867 - Finding Localization Entries for Fragments // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1867 boolean fallbackToFragment = true; // If the bundle is a resolved fragment, then the search for localization data must // delegate to the attached host bundle with the highest version. if (getWiring() != null) { HostBundleRevision highest = null; for (HostBundleRevision hostrev : getAttachedHosts()) { if (highest == null) highest = hostrev; if (highest.getVersion().compareTo(hostrev.getVersion()) < 0) highest = hostrev; } if (highest == null) throw FrameworkMessages.MESSAGES.illegalStateCannotObtainAttachedHost(this); boolean hostUninstalled = highest.getBundleState().isUninstalled(); result = (hostUninstalled ? getEntry(path) : highest.getLocalizationEntry(path)); // In contrary to the spec the TCK ManifestLocalizationTests.testGetHeaders010() // expects to find the localization files in the fragment if they were not found // in the attached host if (result != null || fallbackToFragment == false) return result; } // If the fragment is not resolved, then the framework must search the fragment's JAR for the // localization entry. result = getEntry(path); return result; }
@Override public synchronized ModuleClassLoader getModuleClassLoader() { if (moduleClassLoader == null && getBundle().isResolved()) { ModuleIdentifier identifier = getModuleIdentifier(); try { ModuleManager moduleManager = getFrameworkState().getModuleManager(); Module module = moduleManager.loadModule(identifier); moduleClassLoader = module.getClassLoader(); } catch (ModuleLoadException ex) { throw FrameworkMessages.MESSAGES.illegalStateCannotLoadModule(ex, identifier); } } return moduleClassLoader; }