use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.
the class EquinoxBundle method getModuleClassLoader.
private ModuleClassLoader getModuleClassLoader(boolean logResolveError) {
ResolutionReport report = resolve();
if (logResolveError && !Module.RESOLVED_SET.contains(module.getState())) {
String reportMessage = report.getResolutionReportMessage(module.getCurrentRevision());
equinoxContainer.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, this, new BundleException(reportMessage, BundleException.RESOLVE_ERROR));
}
return AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
@Override
public ModuleClassLoader run() {
ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
if (wiring != null) {
ModuleLoader moduleLoader = wiring.getModuleLoader();
if (moduleLoader instanceof BundleLoader) {
return ((BundleLoader) moduleLoader).getModuleClassLoader();
}
}
return null;
}
});
}
use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.
the class WeavingHookConfigurator method processClass.
public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {
ServiceRegistry registry = getRegistry();
if (registry == null)
// no registry somehow we are loading classes before the registry has been created
return null;
ModuleClassLoader classLoader = manager.getClassLoader();
BundleLoader loader = classLoader.getBundleLoader();
// create a woven class object and add it to the thread local stack
WovenClassImpl wovenClass = new WovenClassImpl(name, classbytes, entry, classpathEntry, loader, container, blackList);
WovenClassContext context = wovenClassContext.get();
if (context == null) {
context = new WovenClassContext();
wovenClassContext.set(context);
}
context.wovenClassStack.add(wovenClass);
// will not have been woven at all.
if (!context.processClassNameStack.contains(name)) {
context.processClassNameStack.add(name);
// call the weaving hooks
try {
return wovenClass.callHooks();
} catch (Throwable t) {
ServiceRegistration<?> errorHook = wovenClass.getErrorHook();
Bundle errorBundle = errorHook != null ? errorHook.getReference().getBundle() : manager.getGeneration().getRevision().getBundle();
container.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, errorBundle, t);
// fail hard with a class loading error
// $NON-NLS-1$
ClassFormatError error = new ClassFormatError("Unexpected error from weaving hook.");
error.initCause(t);
throw error;
} finally {
context.processClassNameStack.remove(name);
}
}
return null;
}
use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.
the class RegisteredPolicy method loadResources.
public Enumeration<URL> loadResources(String name) {
if (allDependents == null)
return null;
Enumeration<URL> results = null;
int size = allDependents.size();
for (int i = 0; i < size; i++) {
try {
ModuleWiring searchWiring = allDependents.get(i);
BundleLoader searchLoader = (BundleLoader) searchWiring.getModuleLoader();
if (searchLoader != null) {
results = BundleLoader.compoundEnumerations(results, searchLoader.findResources(name));
}
} catch (IOException e) {
// Ignore and keep looking
}
}
return results;
}
use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.
the class RegisteredPolicy method loadClass.
public Class<?> loadClass(String name) {
if (allDependents == null)
return null;
Class<?> result = null;
int size = allDependents.size();
for (int i = 0; i < size && result == null; i++) {
ModuleWiring searchWiring = allDependents.get(i);
BundleLoader searchLoader = (BundleLoader) searchWiring.getModuleLoader();
if (searchLoader != null) {
try {
result = searchLoader.findClass(name);
} catch (ClassNotFoundException e) {
// Nothing to do, just keep looking
continue;
}
}
}
return result;
}
use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.
the class RegisteredPolicy method loadResource.
public URL loadResource(String name) {
if (allDependents == null)
return null;
URL result = null;
int size = allDependents.size();
for (int i = 0; i < size && result == null; i++) {
ModuleWiring searchWiring = allDependents.get(i);
BundleLoader searchLoader = (BundleLoader) searchWiring.getModuleLoader();
if (searchLoader != null) {
result = searchLoader.findResource(name);
}
}
return result;
}
Aggregations