Package org.osgi.framework

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


        // Start the bundle. This will make the BundleWiring available on both the bundle and the fragment
        b.start();

        // Check the Bundle Wiring on the fragment. It should only contain the osgi.identity capability
        // All the other capabilities should have migrated to the bundle's BundleWiring.
        BundleWiring fbw = f.adapt(BundleWiring.class);
        List<BundleCapability> fbwCaps = fbw.getCapabilities(null);
        assertEquals("Fragment should only have 1 capability: it's osgi.identity", 1, fbwCaps.size());
        assertCapsEquals(expectedFICap, fbwCaps.get(0));

        // Check the Bundle Wiring on the bundle. It should contain all the capabilities originally on the
View Full Code Here


                + "Export-Package: org.foo.bar;version=\"2.0.0\"\n";
        File feFile = createBundle(femf);

        Bundle fe = felix.getBundleContext().installBundle(feFile.toURI().toASCIIString());

        BundleRevision fbr = fe.adapt(BundleRevision.class);

        List<Capability> feCaps = fbr.getCapabilities("osgi.identity");
        assertEquals(1, feCaps.size());
        Map<String, Object> expectedFEAttrs = new HashMap<String, Object>();
        expectedFEAttrs.put("osgi.identity", "fram.ext");
View Full Code Here

            throw new IllegalArgumentException("Not the system bundle: " + sysbundle);

        // Install system module
        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

    }

    protected boolean resolveBundles(Bundle... bundles) throws Exception {
        Bundle systemBundle = m_context.getBundle(0L);

        FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
        frameworkWiring.resolveBundles(Arrays.asList(bundles));
       
        for (Bundle bundle : bundles) {
            if ((bundle.getState() & Bundle.RESOLVED) == 0) {
                return false;
View Full Code Here

        bundle.start();
    } catch (BundleException e) {
      // TODO use log in future
      e.printStackTrace();
    }
    bundle.adapt(BundleStartLevel.class).setStartLevel(1);
  }

}
View Full Code Here

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will not have an associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(resid);
        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

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will not have an associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(resid);
        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

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will not have an 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

        // 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

                // 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> originRevisions =
                    bundle.adapt(BundleRevisions.class).getRevisions();
                for (int i = originRevisions.size() - 1; i >= 0; i--)
                {
                    BundleRevision originBr = originRevisions.get(i);
                    List<BundleRevision> revisions = Collections.singletonList(originBr);
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.