use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class BundleLoader method clearManifestLocalizationCache.
protected void clearManifestLocalizationCache() {
Generation hostGen = (Generation) wiring.getRevision().getRevisionInfo();
hostGen.clearManifestCache();
List<ModuleWire> hostWires = wiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
// doing a null check because there is no lock on the module database here
if (hostWires != null) {
for (ModuleWire fragmentWire : hostWires) {
Generation fragGen = (Generation) fragmentWire.getRequirer().getRevisionInfo();
fragGen.clearManifestCache();
}
}
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class BundleLoader method getModuleClassLoader.
public ModuleClassLoader getModuleClassLoader() {
ModuleClassLoader result = classloader;
if (result != null) {
return result;
}
// doing optimistic class loader creating here to avoid holding any locks,
// this may result in multiple classloaders being constructed but only one will be used.
final List<ClassLoaderHook> hooks = container.getConfiguration().getHookRegistry().getClassLoaderHooks();
final Generation generation = (Generation) wiring.getRevision().getRevisionInfo();
if (System.getSecurityManager() == null) {
result = createClassLoaderPrivledged(parent, generation.getBundleInfo().getStorage().getConfiguration(), this, generation, hooks);
} else {
final ClassLoader cl = parent;
result = AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
@Override
public ModuleClassLoader run() {
return createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks);
}
});
}
// Not ideal, but hooks really should do little work from classLoaderCreated method.
synchronized (classLoaderCreatedMonitor) {
if (classLoaderCreated == null) {
// must set createdClassloader before calling hooks; otherwise we could enter
// and endless loop if the hook causes re-entry (that would be a bad hook impl)
classLoaderCreated = result;
// only send to hooks if this thread wins in creating the class loader.
final ModuleClassLoader cl = result;
// protect with doPriv to avoid bubbling up permission checks that hooks may require
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
for (ClassLoaderHook hook : hooks) {
hook.classLoaderCreated(cl);
}
return null;
}
});
// finally set the class loader for use after calling hooks
classloader = classLoaderCreated;
} else {
// return the classLoaderCreated here; not the final classloader
// this is necessary in case re-entry by a hook.classLoaderCreated method
result = classLoaderCreated;
if (debug.DEBUG_LOADER) {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.println("BundleLoader[" + this + "].getModuleClassLoader() - created duplicate classloader");
}
}
}
return result;
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class ClasspathManager method loadFragments.
public synchronized void loadFragments(Collection<ModuleRevision> addedFragments) {
List<FragmentClasspath> result = new ArrayList<>(Arrays.asList(fragments));
for (ModuleRevision addedFragment : addedFragments) {
Generation fragGeneration = (Generation) addedFragment.getRevisionInfo();
String[] cp = getClassPath(addedFragment);
ClasspathEntry[] fragEntries = buildClasspath(cp, this, fragGeneration);
FragmentClasspath fragClasspath = new FragmentClasspath(fragGeneration, fragEntries);
insertFragment(fragClasspath, result);
}
fragments = result.toArray(new FragmentClasspath[result.size()]);
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class ClasspathManager method buildFragmentClasspaths.
private FragmentClasspath[] buildFragmentClasspaths(ModuleClassLoader hostloader, ClasspathManager manager) {
if (hostloader == null) {
return emptyFragments;
}
List<ModuleWire> fragmentWires = hostloader.getBundleLoader().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
if (fragmentWires == null || fragmentWires.isEmpty()) {
// we don't hold locks while checking the graph, just return if no longer valid
return emptyFragments;
}
List<FragmentClasspath> result = new ArrayList<>(fragmentWires.size());
for (ModuleWire fragmentWire : fragmentWires) {
ModuleRevision revision = fragmentWire.getRequirer();
Generation fragGeneration = (Generation) revision.getRevisionInfo();
String[] cp = getClassPath(revision);
ClasspathEntry[] fragEntries = buildClasspath(cp, manager, fragGeneration);
FragmentClasspath fragClasspath = new FragmentClasspath(fragGeneration, fragEntries);
insertFragment(fragClasspath, result);
}
return result.toArray(new FragmentClasspath[result.size()]);
}
Aggregations