Package org.osgi.framework.wiring

Examples of org.osgi.framework.wiring.BundleWiring


import ch.lambdaj.group.GroupCondition;

public class DIUtils {

    public static Collection<Class<?>> getBundleClasses(final Bundle bundle, String packagePrefix) {
        BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
        if (bundleWiring == null) {
            throw new IllegalArgumentException("cannot adapt to BundleWiring: " + bundle);
        }
        String resourcePrefix = "/" + packagePrefix.replace('.', '/') + "/";
        Collection<String> resources = bundleWiring.listResources(resourcePrefix, "*.class", LISTRESOURCES_RECURSE);
        return with(resources).convert(new Converter<String, Class<?>>() {

            @Override
            public Class<?> convert(String resource) {
                try {
View Full Code Here


            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

        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

        }

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

            throw new IllegalArgumentException("Not the system bundle: " + syscontext.getBundle());

        // Install system module
        try {
            Resource resource = new DefaultResourceBuilder().addIdentityCapability(getSystemIdentity()).getResource();
            BundleWiring wiring = syscontext.getBundle().adapt(BundleWiring.class);
            installModule(wiring.getClassLoader(), resource, null, null);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }

        installListener = new SynchronousBundleListener() {
View Full Code Here

        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

        Set<Bundle> bundles = tree.flatten();
        Map<String, Set<Bundle>> exports = new HashMap<String, Set<Bundle>>();

        for (Bundle bundle : bundles) {
            for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
                BundleWiring wiring = revision.getWiring();
                if (wiring != null) {
                    List<BundleWire> wires = wiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
                    if (wires != null) {
                        for (BundleWire wire : wires) {
                            String name = wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString();
                            if (exports.get(name) == null) {
                                exports.put(name, new HashSet<Bundle>());
View Full Code Here

     */
    private void createNodeForImport(Node<Bundle> node, Bundle bundle, Clause i) {
        VersionRange range = VersionRange.parseVersionRange(i.getAttribute(Constants.VERSION_ATTRIBUTE));
        boolean foundMatch = false;
        for (Bundle b : bundleContext.getBundles()) {
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> caps = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (caps != null) {
                    for (BundleCapability cap : caps) {
                        String n = getAttribute(cap, BundleRevision.PACKAGE_NAMESPACE);
                        String v = getAttribute(cap, Constants.VERSION_ATTRIBUTE);
                        if (i.getName().equals(n) && range.contains(VersionTable.getVersion(v))) {
View Full Code Here

    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

    }
   
    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

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.