Search in sources :

Example 1 with BundleLoader

use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.

the class EquinoxContainerAdaptor method invalidateWiring.

@Override
public void invalidateWiring(ModuleWiring moduleWiring, ModuleLoader current) {
    if (current instanceof BundleLoader) {
        BundleLoader bundleLoader = (BundleLoader) current;
        bundleLoader.close();
    }
    long updatedTimestamp = storage.getModuleDatabase().getRevisionsTimestamp();
    if (System.getSecurityManager() != null && updatedTimestamp != lastSecurityAdminFlush.getAndSet(updatedTimestamp)) {
        storage.getSecurityAdmin().clearCaches();
        List<Module> modules = storage.getModuleContainer().getModules();
        for (Module module : modules) {
            for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) {
                Generation generation = (Generation) revision.getRevisionInfo();
                if (generation != null) {
                    ProtectionDomain domain = generation.getDomain();
                    if (domain != null) {
                        ((BundlePermissions) domain.getPermissions()).clearPermissionCache();
                    }
                }
            }
        }
    }
    clearManifestCache(moduleWiring);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Generation(org.eclipse.osgi.storage.BundleInfo.Generation) BundlePermissions(org.eclipse.osgi.internal.permadmin.BundlePermissions) SystemModule(org.eclipse.osgi.container.SystemModule) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) SystemBundleLoader(org.eclipse.osgi.internal.loader.SystemBundleLoader) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Example 2 with BundleLoader

use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.

the class BundleContextImpl method loadBundleActivator.

private BundleActivator loadBundleActivator() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    ModuleWiring wiring = bundle.getModule().getCurrentRevision().getWiring();
    if (wiring == null) {
        return null;
    }
    BundleLoader loader = (BundleLoader) wiring.getModuleLoader();
    if (loader == null) {
        return null;
    }
    List<Capability> metadata = wiring.getRevision().getCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE);
    if (metadata.isEmpty()) {
        return null;
    }
    String activatorName = (String) metadata.get(0).getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_ACTIVATOR);
    if (activatorName == null) {
        return null;
    }
    Class<?> activatorClass = loader.findClass(activatorName);
    return (BundleActivator) activatorClass.newInstance();
}
Also used : Capability(org.osgi.resource.Capability) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Example 3 with BundleLoader

use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.

the class DependentPolicy method loadResource.

public URL loadResource(String name) {
    if (allDependents == null)
        return null;
    URL result = null;
    // size may change, so we must check it every time
    for (int i = 0; i < allDependents.size() && result == null; i++) {
        ModuleWiring searchWiring = allDependents.get(i);
        BundleLoader searchLoader = (BundleLoader) searchWiring.getModuleLoader();
        if (searchLoader != null) {
            result = searchLoader.findResource(name);
            if (result == null) {
                addDependent(i, searchWiring);
            }
        }
    }
    return result;
}
Also used : ModuleWiring(org.eclipse.osgi.container.ModuleWiring) URL(java.net.URL) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Example 4 with BundleLoader

use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.

the class DependentPolicy method loadClass.

public Class<?> loadClass(String name) {
    if (allDependents == null)
        return null;
    Class<?> result = null;
    // size may change, so we must check it every time
    for (int i = 0; i < allDependents.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) {
                if (result == null)
                    addDependent(i, searchWiring);
            }
        }
    }
    return result;
}
Also used : ModuleWiring(org.eclipse.osgi.container.ModuleWiring) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Example 5 with BundleLoader

use of org.eclipse.osgi.internal.loader.BundleLoader in project rt.equinox.framework by eclipse.

the class PackageSource method getPackageSource.

private static PackageSource getPackageSource(Class<?> serviceClass, String pkgName, @SuppressWarnings("deprecation") PackageAdmin packageAdmin) {
    if (serviceClass == null)
        return null;
    @SuppressWarnings("deprecation") Bundle serviceBundle = packageAdmin.getBundle(serviceClass);
    if (serviceBundle == null)
        return null;
    BundleLoader producerBL = getBundleLoader(serviceBundle);
    if (producerBL == null)
        return null;
    PackageSource producerSource = producerBL.getPackageSource(pkgName);
    if (producerSource != null)
        return producerSource;
    // try the interfaces
    Class<?>[] interfaces = serviceClass.getInterfaces();
    // note that getInterfaces never returns null
    for (int i = 0; i < interfaces.length; i++) {
        producerSource = getPackageSource(interfaces[i], pkgName, packageAdmin);
        if (producerSource != null)
            return producerSource;
    }
    // try super class
    return getPackageSource(serviceClass.getSuperclass(), pkgName, packageAdmin);
}
Also used : EquinoxBundle(org.eclipse.osgi.internal.framework.EquinoxBundle) Bundle(org.osgi.framework.Bundle) SystemBundleLoader(org.eclipse.osgi.internal.loader.SystemBundleLoader) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Aggregations

BundleLoader (org.eclipse.osgi.internal.loader.BundleLoader)12 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)8 URL (java.net.URL)4 SystemBundleLoader (org.eclipse.osgi.internal.loader.SystemBundleLoader)3 IOException (java.io.IOException)2 EquinoxBundle (org.eclipse.osgi.internal.framework.EquinoxBundle)2 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)2 Bundle (org.osgi.framework.Bundle)2 ProtectionDomain (java.security.ProtectionDomain)1 Module (org.eclipse.osgi.container.Module)1 ModuleLoader (org.eclipse.osgi.container.ModuleLoader)1 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)1 SystemModule (org.eclipse.osgi.container.SystemModule)1 BundlePermissions (org.eclipse.osgi.internal.permadmin.BundlePermissions)1 ServiceRegistry (org.eclipse.osgi.internal.serviceregistry.ServiceRegistry)1 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)1 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)1 BundleException (org.osgi.framework.BundleException)1 ServiceFactory (org.osgi.framework.ServiceFactory)1 Capability (org.osgi.resource.Capability)1