Examples of BundleWiring


Examples of org.osgi.framework.wiring.BundleWiring

            {
                System.out.println("");
            }

            // Print out any matching generic capabilities.
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null)
            {
                String title = b + " provides:";
                System.out.println(title);
                System.out.println(Util.getUnderlineString(title.length()));
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            {
                System.out.println("");
            }

            // Print out any matching generic requirements.
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null)
            {
                String title = b + " requires:";
                System.out.println(title);
                System.out.println(Util.getUnderlineString(title.length()));
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            for (Entry<BundleRevision, BundleWiringImpl> entry : wirings.entrySet())
            {
                BundleRevisionImpl revision = (BundleRevisionImpl) entry.getKey();

                // Mark revision as resolved.
                BundleWiring wiring = entry.getValue();
                revision.resolve(entry.getValue());

                // Record dependencies.
                for (BundleWire bw : wiring.getRequiredWires(null))
                {
                    m_felix.getDependencies().addDependent(bw);
                }

                // Reindex the revision's capabilities since its resolved
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        // 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
        // bundle and also contain the osgi.wiring.package capability from the fragment.
        BundleWiring bbw = b.adapt(BundleWiring.class);
        List<BundleCapability> bwbCaps2 = bbw.getCapabilities("osgi.wiring.bundle");
        assertEquals(1, bwbCaps2.size());
        assertCapsEquals(expectedBWBCap, bwbCaps2.get(0));
        List<BundleCapability> bwhCaps2 = bbw.getCapabilities("osgi.wiring.host");
        assertEquals(1, bwhCaps2.size());
        assertCapsEquals(expectedBWHCap, bwhCaps2.get(0));
        List<BundleCapability> bwiCaps2 = bbw.getCapabilities("osgi.identity");
        assertEquals(1, bwiCaps2.size());
        assertCapsEquals(expectedBWICap, bwiCaps2.get(0));
        List<BundleCapability> bwpCaps2 = bbw.getCapabilities("osgi.wiring.package");
        assertEquals("Bundle should have inherited the osgi.wiring.package capability from the fragment",
                1, bwpCaps2.size());
        assertCapsEquals(expectedFWCap, bwpCaps2.get(0));
    }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            this.bundleContext.removeBundleListener(listener);
        }
    }

    protected boolean isPackageExported(Bundle b, String packageName) {
        final BundleWiring wiring = b.adapt(BundleWiring.class);
        assertNotNull("Expecting non-null BundleWiring for bundle " + b, wiring);
        for(BundleCapability c : wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) {
            if(packageName.equals(c.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE))) {
                return true;
            }
        }
        return false;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            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);
        }

        // Create the {@link URLStreamHandlerTracker}
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        Module module = getModule(bundle.getBundleId());
        if (module != null)
            return module;

        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        ClassLoader classLoader = wiring != null ? wiring.getClassLoader() : null;
        if (classLoader == null)
            return null;

        Resource resource = ThreadResourceAssociation.getResource();
        Dictionary<String, String> headers = bundle.getHeaders();
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        }
    }

    private void loadImplementationsInBundle(final Test test, final String packageName) {
        //Do not remove the cast on the next line as removing it will cause a compile error on Java 7.
        final BundleWiring wiring = (BundleWiring) FrameworkUtil.getBundle(
                ResolverUtil.class).adapt(BundleWiring.class);
        final Collection<String> list = wiring.listResources(packageName, "*.class",
            BundleWiring.LISTRESOURCES_RECURSE);
        for (final String name : list) {
            addIfMatching(test, name);
        }
    }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        // 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) {
                throw new ProvisionException(ex);
            }
        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        // 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) {
                throw new ProvisionException(ex);
            }
        }
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.