Search in sources :

Example 1 with ServiceRegistry

use of org.eclipse.osgi.internal.serviceregistry.ServiceRegistry in project rt.equinox.framework by eclipse.

the class EquinoxContainer method init.

void init() {
    eventPublisher.init();
    synchronized (this.monitor) {
        serviceRegistry = new ServiceRegistry(this);
        initializeContextFinder();
        executor = Executors.newScheduledThreadPool(1, this);
        // be sure to initialize the executor threads
        executor.execute(this);
        storageSaver = new StorageSaver(this);
    }
}
Also used : ServiceRegistry(org.eclipse.osgi.internal.serviceregistry.ServiceRegistry)

Example 2 with ServiceRegistry

use of org.eclipse.osgi.internal.serviceregistry.ServiceRegistry 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;
}
Also used : ModuleClassLoader(org.eclipse.osgi.internal.loader.ModuleClassLoader) ServiceRegistry(org.eclipse.osgi.internal.serviceregistry.ServiceRegistry) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Aggregations

ServiceRegistry (org.eclipse.osgi.internal.serviceregistry.ServiceRegistry)2 BundleLoader (org.eclipse.osgi.internal.loader.BundleLoader)1 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)1