Search in sources :

Example 1 with ModuleRevision

use of org.eclipse.osgi.container.ModuleRevision 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 ModuleRevision

use of org.eclipse.osgi.container.ModuleRevision in project rt.equinox.framework by eclipse.

the class PackageAdminImpl method getWiring.

private ModuleWiring getWiring(Bundle bundle) {
    Module module = StartLevelImpl.getModule(bundle);
    if (module == null) {
        return null;
    }
    List<ModuleRevision> revisions = module.getRevisions().getModuleRevisions();
    if (revisions.isEmpty()) {
        return null;
    }
    return revisions.get(0).getWiring();
}
Also used : Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 3 with ModuleRevision

use of org.eclipse.osgi.container.ModuleRevision in project rt.equinox.framework by eclipse.

the class BundleLoader method findDynamicSource.

private PackageSource findDynamicSource(String pkgName) {
    if (!isExportedPackage(pkgName) && isDynamicallyImported(pkgName)) {
        if (debug.DEBUG_LOADER) {
            // $NON-NLS-1$ //$NON-NLS-2$
            Debug.println("BundleLoader[" + this + "] attempting to resolve dynamic package: " + pkgName);
        }
        ModuleRevision revision = wiring.getRevision();
        ModuleWire dynamicWire = revision.getRevisions().getModule().getContainer().resolveDynamic(pkgName, revision);
        if (dynamicWire != null) {
            PackageSource source = createExportPackageSource(dynamicWire, null);
            if (debug.DEBUG_LOADER) {
                // $NON-NLS-1$ //$NON-NLS-2$
                Debug.println("BundleLoader[" + this + "] using dynamic import source: " + source);
            }
            synchronized (importedSources) {
                importedSources.add(source);
            }
            return source;
        }
    }
    return null;
}
Also used : ModuleWire(org.eclipse.osgi.container.ModuleWire) PackageSource(org.eclipse.osgi.internal.loader.sources.PackageSource) NullPackageSource(org.eclipse.osgi.internal.loader.sources.NullPackageSource) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 4 with ModuleRevision

use of org.eclipse.osgi.container.ModuleRevision in project rt.equinox.framework by eclipse.

the class ServiceRegistry method hasListenServicePermission.

/**
 * Check for permission to listen to a service.
 */
static boolean hasListenServicePermission(ServiceEvent event, BundleContextImpl context) {
    ModuleRevision revision = context.getBundleImpl().getModule().getCurrentRevision();
    if (revision == null) {
        return false;
    }
    ProtectionDomain domain = ((Generation) revision.getRevisionInfo()).getDomain();
    if (domain == null) {
        return true;
    }
    return domain.implies(new ServicePermission(event.getServiceReference(), ServicePermission.GET));
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 5 with ModuleRevision

use of org.eclipse.osgi.container.ModuleRevision in project rt.equinox.framework by eclipse.

the class BundleLocalizationImpl method getLocalization.

/**
 * The getLocalization method gets a ResourceBundle object for the given
 * locale and bundle.
 *
 * @return A <code>ResourceBundle</code> object for the given bundle and locale.
 * If null is passed for the locale parameter, the default locale is used.
 */
public ResourceBundle getLocalization(Bundle bundle, String locale) {
    Module m = ((EquinoxBundle) bundle).getModule();
    ModuleRevision r = m.getCurrentRevision();
    Generation g = (Generation) r.getRevisionInfo();
    return g.getResourceBundle(locale);
}
Also used : EquinoxBundle(org.eclipse.osgi.internal.framework.EquinoxBundle) Generation(org.eclipse.osgi.storage.BundleInfo.Generation) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Aggregations

ModuleRevision (org.eclipse.osgi.container.ModuleRevision)35 Module (org.eclipse.osgi.container.Module)21 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)15 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)12 ArrayList (java.util.ArrayList)9 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)9 ModuleWire (org.eclipse.osgi.container.ModuleWire)9 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)8 Test (org.junit.Test)8 BundleException (org.osgi.framework.BundleException)5 IOException (java.io.IOException)4 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)4 File (java.io.File)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 SystemModule (org.eclipse.osgi.container.SystemModule)3 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)3 DirBundleFile (org.eclipse.osgi.storage.bundlefile.DirBundleFile)3 NestedDirBundleFile (org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile)3 ZipBundleFile (org.eclipse.osgi.storage.bundlefile.ZipBundleFile)3