Search in sources :

Example 1 with Module

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

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

the class PackageAdminImpl method getBundleType.

public int getBundleType(Bundle bundle) {
    Module module = StartLevelImpl.getModule(bundle);
    if (module == null) {
        return 0;
    }
    List<BundleRevision> revisions = module.getRevisions().getRevisions();
    if (revisions.isEmpty()) {
        return 0;
    }
    return (revisions.get(0).getTypes() & BundleRevision.TYPE_FRAGMENT) != 0 ? PackageAdmin.BUNDLE_TYPE_FRAGMENT : 0;
}
Also used : BundleRevision(org.osgi.framework.wiring.BundleRevision) Module(org.eclipse.osgi.container.Module)

Example 3 with Module

use of org.eclipse.osgi.container.Module 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 4 with Module

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

the class EclipseLazyStarter method postFindLocalClass.

@Override
public void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager) throws ClassNotFoundException {
    if (initiatingClassName.get() != name)
        return;
    initiatingClassName.set(null);
    Deque<ClasspathManager> stack = activationStack.get();
    if (stack == null || stack.isEmpty())
        return;
    // if we have a stack we must clear it even if (clazz == null)
    List<ClasspathManager> managers = new ArrayList<>(stack);
    stack.clear();
    if (clazz == null)
        return;
    for (ClasspathManager managerElement : managers) {
        if (errors.get(managerElement) != null) {
            if (container.getConfiguration().throwErrorOnFailedStart)
                throw errors.get(managerElement);
            continue;
        }
        // The bundle must be started.
        // Note that another thread may already be starting this bundle;
        // In this case we will timeout after a default of 5 seconds and record the BundleException
        long startTime = System.currentTimeMillis();
        Module m = managerElement.getGeneration().getRevision().getRevisions().getModule();
        try {
            // do not persist the start of this bundle
            secureAction.start(m, StartOptions.LAZY_TRIGGER);
        } catch (BundleException e) {
            Bundle bundle = managerElement.getGeneration().getRevision().getBundle();
            if (e.getType() == BundleException.STATECHANGE_ERROR) {
                String message = NLS.bind(Msg.ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP, new Object[] { Thread.currentThread(), name, m.getStateChangeOwner(), bundle, new Long(System.currentTimeMillis() - startTime) });
                container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, message, e);
                continue;
            }
            String message = NLS.bind(Msg.ECLIPSE_CLASSLOADER_ACTIVATION, bundle.getSymbolicName(), Long.toString(bundle.getBundleId()));
            ClassNotFoundException error = new ClassNotFoundException(message, e);
            errors.put(managerElement, error);
            if (container.getConfiguration().throwErrorOnFailedStart) {
                container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, message, e, null);
                throw error;
            }
            container.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(message, e));
        }
    }
}
Also used : ClasspathManager(org.eclipse.osgi.internal.loader.classpath.ClasspathManager) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) BundleException(org.osgi.framework.BundleException) Module(org.eclipse.osgi.container.Module)

Example 5 with Module

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

the class BundleContextImpl method getBundles.

/**
 * Retrieve a list of all installed bundles.
 * The list is valid at the time
 * of the call to getBundles, but the framework is a very dynamic
 * environment and bundles can be installed or uninstalled at anytime.
 *
 * @return An array of {@link Bundle} objects, one
 * object per installed bundle.
 */
public Bundle[] getBundles() {
    List<Module> modules = container.getStorage().getModuleContainer().getModules();
    List<Bundle> bundles = new ArrayList<>(modules.size());
    for (Module module : modules) {
        bundles.add(module.getBundle());
    }
    notifyFindHooks(this, bundles);
    return bundles.toArray(new Bundle[bundles.size()]);
}
Also used : Module(org.eclipse.osgi.container.Module)

Aggregations

Module (org.eclipse.osgi.container.Module)119 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)92 Test (org.junit.Test)84 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)79 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)36 ModuleWire (org.eclipse.osgi.container.ModuleWire)32 HashMap (java.util.HashMap)23 ArrayList (java.util.ArrayList)22 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)22 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)21 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)12 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)10 BundleException (org.osgi.framework.BundleException)10 DummyModuleEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent)9 ModuleRevisionBuilder (org.eclipse.osgi.container.ModuleRevisionBuilder)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DataInputStream (java.io.DataInputStream)6 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)6 DummyCollisionHook (org.eclipse.osgi.tests.container.dummys.DummyCollisionHook)6