Package org.osgi.framework.wiring

Examples of org.osgi.framework.wiring.BundleWiring


    }
   
    private boolean canBeSatisfied(BundleRequirement req) {
        Bundle[] bundles = bundleContext.getBundles();
        for (Bundle bundle : bundles) {
            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> caps = wiring.getCapabilities(null);
                for (BundleCapability cap : caps) {
                    if (req.matches(cap)) {
                        return true;
                    }
                }
View Full Code Here


    public Map<String, Bundle> getWiredBundles(Bundle bundle) {
        // the set of bundles from which the bundle imports packages
        Map<String, Bundle> exporters = new HashMap<String, Bundle>();

        for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
            BundleWiring wiring = revision.getWiring();
            if (wiring != null) {
                List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
                if (wires != null) {
                    for (BundleWire wire : wires) {
                        if (wire.getProviderWiring().getBundle().getBundleId() != 0) {
                            exporters.put(wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString(),
                                          wire.getProviderWiring().getBundle());
View Full Code Here

        }
    }

    private static ClassLoader getClassloader(Bundle b) {
        //Somehow it fails to compile on JDK 7. Explicit cast helps
        BundleWiring bw = (BundleWiring) b.adapt(BundleWiring.class);
        if(bw != null){
            return bw.getClassLoader();
        }
        return null;
    }
View Full Code Here

        String directory = path.substring(0, path.lastIndexOf('/'));
        String filename = path.substring(path.lastIndexOf('/') + 1);

        for (Bundle bundle : bundleContext.getBundles()) {

            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            List<URL> entries = wiring.findEntries(directory, filename, 0);
            for (URL url : entries) {
                try {
                    return Streams.readBytes(url.openStream());
                } catch (IOException e) {
                    // Ignore and move to the next source
View Full Code Here

        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

            m_classPathIdx = 0;
        }
        if (!((BundleRevisionImpl) m_targetRevision)
            .hasInputStream(m_classPathIdx, url.getPath()))
        {
            BundleWiring wiring = m_targetRevision.getWiring();
            ClassLoader cl = (wiring != null) ? wiring.getClassLoader() : null;
            URL newurl = (cl != null) ? cl.getResource(url.getPath()) : null;
            if (newurl == null)
            {
                throw new IOException("Resource does not exist: " + url);
            }
View Full Code Here

        {
            // The wires are supposed to be in declared capability order, so
            // get the capability list from the revision's wiring, which is
            // in declared order (including fragments), and use it to create
            // the provided wire list in declared order.
            BundleWiring wiring = revision.getWiring();
            if (wiring != null)
            {
                List<BundleCapability> resolvedCaps = wiring.getCapabilities(namespace);
                for (BundleCapability resolvedCap : resolvedCaps)
                {
                    Set<BundleWire> dependentWires = providedCaps.get(resolvedCap);
                    if (dependentWires != null)
                    {
View Full Code Here

        {
            // We need to special case fragments,
            // since their dependents are their hosts.
            if (Util.isFragment(revision))
            {
                BundleWiring wiring = revision.getWiring();
                if (wiring != null)
                {
                    for (BundleWire bw : wiring.getRequiredWires(null))
                    {
                        result.add(((BundleWireImpl) bw).getProvider().getBundle());
                    }
                }
            }
View Full Code Here

    public synchronized void removeDependencies(Bundle bundle)
    {
        List<BundleRevision> revs = bundle.adapt(BundleRevisions.class).getRevisions();
        for (BundleRevision rev : revs)
        {
            BundleWiring wiring = rev.getWiring();
            if (wiring != null)
            {
                for (BundleWire bw : wiring.getRequiredWires(null))
                {
                    Map<BundleCapability, Set<BundleWire>> caps =
                        m_dependentsMap.get(bw.getProvider());
                    if (caps != null)
                    {
View Full Code Here

        }

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

TOP

Related Classes of org.osgi.framework.wiring.BundleWiring

Copyright © 2018 www.massapicom. 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.