Examples of BundleWiring


Examples of org.osgi.framework.wiring.BundleWiring

    private boolean checkPackage(String packageName, String version) {
        VersionRange range = VersionRange.parseVersionRange(version);
        Bundle[] bundles = bundleContext.getBundles();
        for (int i = 0; (bundles != null) && (i < bundles.length); i++) {
            BundleWiring wiring = bundles[i].adapt(BundleWiring.class);
            List<BundleCapability> caps = wiring != null ? wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE) : null;
            if (caps != null) {
                for (BundleCapability cap : caps) {
                    String n = getAttribute(cap, BundleRevision.PACKAGE_NAMESPACE);
                    String v = getAttribute(cap, Constants.VERSION_ATTRIBUTE);
                    if (packageName.equals(n) && range.contains(VersionTable.getVersion(v))) {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            printResources(bundle);
        }
    }

    protected void printResources(Bundle bundle) {
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (wiring != null){
            Collection<String> resources;
            if (displayAllFiles){
                resources = wiring.listResources("/", null, BundleWiring.LISTRESOURCES_RECURSE);
            }else{
                resources = wiring.listResources("/", "*class", BundleWiring.LISTRESOURCES_RECURSE);
            }
            for (String resource:resources){
                System.out.println(resource);
            }
        } else {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            if (separatorNeeded) {
                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(ShellUtil.getUnderlineString(title));
                boolean matches = printMatchingRequirements(wiring, ns);
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        }

        // Create a list of the revision and any attached fragment revisions.
        List<BundleRevision> result = new ArrayList<BundleRevision>();
        result.add(br);
        BundleWiring wiring = br.getWiring();
        if (wiring != null)
        {
            List<BundleRevision> fragments = Util.getFragments(wiring);
            if (fragments != null)
            {
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 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) {
                throw new ProvisionException(ex);
            }
        }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

   
    // OSGi 4.3 API
   
    private static LinkedHashSet<Bundle> getWiredBundles43(Bundle bundle) {
        LinkedHashSet<Bundle> wiredBundles = new LinkedHashSet<Bundle>();
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (wiring != null) {
            List<BundleWire> wires;
            wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
            for (BundleWire wire : wires) {
                wiredBundles.add(wire.getProviderWiring().getBundle());
            }
            wires = wiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE);
            for (BundleWire wire : wires) {
                wiredBundles.add(wire.getProviderWiring().getBundle());
            }
        }       
        return wiredBundles;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        // skip first bundle
        iterator.next();
        // attempt to load the class from the remaining bundles
        while (iterator.hasNext()) {
            Bundle bundle = iterator.next();
            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> capabilities = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (capabilities != null && !capabilities.isEmpty()) {
                    for (BundleCapability capability : capabilities) {
                        Map<String, Object> attributes = capability.getAttributes();
                        if (attributes != null) {
                            String packageName = String.valueOf(attributes.get(BundleRevision.PACKAGE_NAMESPACE));
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            if (fragmentCands != null)
            {
                for (BundleCapability fragCand : fragmentCands)
                {
                    // Only necessary for resolved fragments.
                    BundleWiring wiring = fragCand.getRevision().getWiring();
                    if (wiring != null)
                    {
                        // Fragments only have host wire, so each wire represents
                        // an attached host.
                        for (BundleWire wire : wiring.getRequiredWires(null))
                        {
                            // If the capability is a package, then make sure the
                            // host actually provides it in its resolved capabilities,
                            // since it may be a substitutable export.
                            if (!fragCand.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        }).anyTimes();
        EasyMock.replay(providerBC);

        // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
        // a coverage tool such as EclEmma). This will satisfy that.
        BundleWiring bw = EasyMock.createMock(BundleWiring.class);
        EasyMock.expect(bw.getClassLoader()).andReturn(getClass().getClassLoader()).anyTimes();
        EasyMock.replay(bw);

        // The mock bundle that provides the original service (and also the proxy is registered with this)
        Bundle providerBundle = EasyMock.createNiceMock(Bundle.class);
        EasyMock.expect(providerBundle.getBundleContext()).andReturn(providerBC).anyTimes();
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        EasyMock.replay(providerBC);

        // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
        // a coverage tool such as EclEmma). This will satisfy that.
        BundleWiring bw = EasyMock.createMock(BundleWiring.class);
        EasyMock.expect(bw.getClassLoader()).andReturn(getClass().getClassLoader()).anyTimes();
        EasyMock.replay(bw);

        // The mock bundle that provides the original service (and also the proxy is registered with this)
        Bundle providerBundle = EasyMock.createNiceMock(Bundle.class);
        EasyMock.expect(providerBundle.getBundleContext()).andReturn(providerBC).anyTimes();
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.