Package org.osgi.framework

Examples of org.osgi.framework.Bundle.adapt()


        // Install system module
        Bundle sysbundle = context.getBundle(0);
        try {
            Resource resource = new DefaultResourceBuilder().addIdentityCapability(getSystemIdentity()).getResource();
            BundleWiring wiring = sysbundle.adapt(BundleWiring.class);
            installModule(wiring.getClassLoader(), resource, sysbundle.getHeaders(), null);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }
View Full Code Here


        // Install system module
        Bundle sysbundle = context.getBundle(0);
        try {
            Resource resource = new DefaultResourceBuilder().addIdentityCapability(getSystemIdentity()).getResource();
            BundleWiring wiring = sysbundle.adapt(BundleWiring.class);
            installModule(wiring.getClassLoader(), resource, sysbundle.getHeaders(), null);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }
View Full Code Here

                Deployment andep = method.getAnnotation(Deployment.class);
                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    int bundleStartLevel = method.getAnnotation(StartLevelAware.class).startLevel();
                    Bundle bundle = getBundle(testCase);
                    log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                    BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                    startLevel.setStartLevel(bundleStartLevel);
                }
            }
        }
    }
View Full Code Here

public class BundleInformation {

    public static void showSWTBotDependencies() {
        log("commencing showSWTBotDependencies");
        Bundle bundle = FrameworkUtil.getBundle(SWTBot.class);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        List<BundleWire> requiredWires = wiring.getRequiredWires(null);
        for (BundleWire requiredWire : requiredWires) {
            log("requiredWire: " + requiredWire);
        }
        log("completed showSWTBotDependencies");
View Full Code Here

                // bundle JAR file is represented as a revision ordered from
                // newest to oldest. We assume that the first revision found to
                // be exporting the package is the provider of the package,
                // which makes sense since it must have been resolved first.
                List<BundleRevision> revisions =
                    bundle.adapt(BundleRevisions.class).getRevisions();
                for (int i = revisions.size() - 1; i >= 0; i--)
                {
                    BundleRevision br = revisions.get(i);
                    List<BundleCapability> caps = (br.getWiring() == null)
                        ? br.getDeclaredCapabilities(null)
View Full Code Here

    private void installAndStartBundles(ArtifactResolver resolver, BundleContext context, List<BundleInfo> bundles) {
        for (BundleInfo bundleInfo : bundles) {
            try {
                URI resolvedURI = resolver.resolve(bundleInfo.uri);
                Bundle b = context.installBundle(bundleInfo.uri.toString(), resolvedURI.toURL().openStream());
                b.adapt(BundleStartLevel.class).setStartLevel(bundleInfo.startLevel);
                if (isNotFragment(b)) {
                    b.start();
                }
            } catch (Exception  e) {
                throw new RuntimeException("Error installing bundle listed in " + STARTUP_PROPERTIES_FILE_NAME
View Full Code Here

            }
            LOGGER.debug("Installing bundle " + bundleLocation);
            Bundle b = bundleContext.installBundle(bundleLocation, is);
           
            if (startLevel > 0) {
                b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
            }

            return new BundleInstallerResult(b, true);
        } finally {
            is.close();
View Full Code Here

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will have no associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identity);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (module == null && wiring != null) {
            try {
                ClassLoader classLoader = wiring.getClassLoader();
                module = runtime.installModule(classLoader, resource, null);
            } catch (ModuleException ex) {
View Full Code Here

  }

  protected void verifyBundleWiring() {
    Bundle bundle = Mockito.verify(_bundle);

    bundle.adapt(BundleWiring.class);

    BundleWiring bundleWiring = Mockito.verify(_bundleWiring);

    bundleWiring.getClassLoader();
  }
View Full Code Here

        modified.set(true);

        // Set default start level at install time, the user can override it if he wants
        if (startLevel != 0)
        {
            b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
        }
       
        return b;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.