Package aQute.bnd.osgi.resource

Examples of aQute.bnd.osgi.resource.CapReqBuilder


    public static List<Resource> findResources(Repository repository, String bsn, String version) {
        return findResources(repository, bsn, version, "*");
    }

    public static List<Resource> findResources(Repository repository, String bsn, String version, String type) {
        Requirement requirement = new CapReqBuilder("osgi.identity")
            .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=%s))", bsn, version, type))
            .buildSyntheticRequirement();
        return findResources(repository, requirement);
    }
View Full Code Here


    }

    public static List<Resource> findResources(Repository repository, Requirement requirement) {
        if (requirement == null) {
            // FIXME maybe we can just pass null
            requirement = new CapReqBuilder("osgi.identity")
                .addDirective("filter", "(&(osgi.identity=*)(version=*)(type=*))")
                .buildSyntheticRequirement();
        }

        Map<Requirement, Collection<Capability>> sourceResources = repository.findProviders(Collections.singleton(requirement));
View Full Code Here

            addEECapability(capIndex, compatibleEE);
        }

        // Add system.bundle alias
        Version frameworkVersion = Utils.findIdentityVersion(frameworkResource);
        capIndex.addCapability(new CapReqBuilder(BundleNamespace.BUNDLE_NAMESPACE).addAttribute(BundleNamespace.BUNDLE_NAMESPACE, Constants.SYSTEM_BUNDLE_SYMBOLICNAME)
                .addAttribute(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, frameworkVersion).setResource(frameworkResource).buildCapability());
        capIndex.addCapability(new CapReqBuilder(HostNamespace.HOST_NAMESPACE).addAttribute(HostNamespace.HOST_NAMESPACE, Constants.SYSTEM_BUNDLE_SYMBOLICNAME)
                .addAttribute(HostNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, frameworkVersion).setResource(frameworkResource).buildCapability());

        // Add JRE packages
        loadJREPackages();

        // Add system.packages.extra
        if (sysPkgsExtra != null)
            for (ExportedPackage sysPkg : sysPkgsExtra) {
                CapReqBuilder builder = new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE);
                builder.addAttribute(PackageNamespace.PACKAGE_NAMESPACE, sysPkg.getName());
                String versionStr = sysPkg.getVersionString();
                Version version = versionStr != null ? new Version(versionStr) : Version.emptyVersion;
                builder.addAttribute(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
                Capability cap = builder.setResource(framework).buildCapability();
                capIndex.addCapability(cap);
            }

        // Add system capabilities extra
        if (sysCapsExtraParams != null) {
            for (Entry<String,Attrs> entry : sysCapsExtraParams.entrySet()) {
                CapReqBuilder builder = new CapReqBuilder(entry.getKey());
                for (String attrKey : entry.getValue().keySet()) {
                    if (attrKey.endsWith(":")) {
                        String directiveKey = attrKey.substring(0, attrKey.length() - 1);
                        builder.addDirective(directiveKey, entry.getValue().get(attrKey));
                    } else {
                        builder.addAttribute(attrKey, entry.getValue().getTyped(attrKey));
                    }
                }
                builder.setResource(frameworkResource);
                capIndex.addCapability(builder.buildCapability());
            }
        }
    }
View Full Code Here

        Capability cap = builder.setResource(framework).buildCapability();
        capIndex.addCapability(cap);
    }

    private void addEECapability(CapabilityIndex index, EE ee) {
        CapReqBuilder builder;

        // Correct version according to R5 specification section 3.4.1
        // BREE J2SE-1.4 ==> osgi.ee=JavaSE, version:Version=1.4
        // See bug 329, https://github.com/bndtools/bnd/issues/329
        builder = new CapReqBuilder(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
        builder.addAttribute(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, ee.getCapabilityName());
        builder.addAttribute(ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE, ee.getCapabilityVersion());
        builder.setResource(framework);
        index.addCapability(builder.buildCapability());

        // Compatibility with old version...
        builder = new CapReqBuilder(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
        builder.addAttribute(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, ee.getEEName());
        builder.setResource(framework);
        index.addCapability(builder.buildCapability());
    }
View Full Code Here

                Properties properties = new Properties();
                properties.load(stream);

                Parameters params = new Parameters(properties.getProperty("org.osgi.framework.system.packages", ""));
                for (String packageName : params.keySet()) {
                    CapReqBuilder builder = new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE);
                    builder.addAttribute(PackageNamespace.PACKAGE_NAMESPACE, packageName);
                    builder.addAttribute(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, new Version(0, 0, 0));
                    Capability cap = builder.setResource(framework).buildCapability();
                    capIndex.addCapability(cap);
                }
            } catch (IOException e) {
                throw new IllegalStateException("Error loading JRE package properties", e);
            }
View Full Code Here

            addEECapability(capIndex, compatibleEE);
        }

        // Add system.bundle alias
        Version frameworkVersion = Utils.findIdentityVersion(frameworkResource);
        capIndex.addCapability(new CapReqBuilder(BundleNamespace.BUNDLE_NAMESPACE).addAttribute(BundleNamespace.BUNDLE_NAMESPACE, Constants.SYSTEM_BUNDLE_SYMBOLICNAME)
                .addAttribute(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, frameworkVersion).setResource(frameworkResource).buildCapability());
        capIndex.addCapability(new CapReqBuilder(HostNamespace.HOST_NAMESPACE).addAttribute(HostNamespace.HOST_NAMESPACE, Constants.SYSTEM_BUNDLE_SYMBOLICNAME)
                .addAttribute(HostNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, frameworkVersion).setResource(frameworkResource).buildCapability());

        // Add JRE packages
        loadJREPackages();

        // Add system.packages.extra
        if (sysPkgsExtra != null)
            for (ExportedPackage sysPkg : sysPkgsExtra) {
                CapReqBuilder builder = new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE);
                builder.addAttribute(PackageNamespace.PACKAGE_NAMESPACE, sysPkg.getName());
                String versionStr = sysPkg.getVersionString();
                Version version = versionStr != null ? new Version(versionStr) : Version.emptyVersion;
                builder.addAttribute(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
                Capability cap = builder.setResource(framework).buildCapability();
                capIndex.addCapability(cap);
            }

        // Add system capabilities extra
        if (sysCapsExtraParams != null) {
            for (Entry<String,Attrs> entry : sysCapsExtraParams.entrySet()) {
                CapReqBuilder builder = new CapReqBuilder(entry.getKey());
                for (String attrKey : entry.getValue().keySet()) {
                    if (attrKey.endsWith(":")) {
                        String directiveKey = attrKey.substring(0, attrKey.length() - 1);
                        builder.addDirective(directiveKey, entry.getValue().get(attrKey));
                    } else {
                        builder.addAttribute(attrKey, entry.getValue().getTyped(attrKey));
                    }
                }
                builder.setResource(frameworkResource);
                capIndex.addCapability(builder.buildCapability());
            }
        }
    }
View Full Code Here

        Capability cap = builder.setResource(framework).buildCapability();
        capIndex.addCapability(cap);
    }

    private void addEECapability(CapabilityIndex index, EE ee) {
        CapReqBuilder builder;

        // Correct version according to R5 specification section 3.4.1
        // BREE J2SE-1.4 ==> osgi.ee=JavaSE, version:Version=1.4
        // See bug 329, https://github.com/bndtools/bnd/issues/329
        builder = new CapReqBuilder(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
        builder.addAttribute(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, ee.getCapabilityName());
        builder.addAttribute(ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE, ee.getCapabilityVersion());
        builder.setResource(framework);
        index.addCapability(builder.buildCapability());

        // Compatibility with old version...
        builder = new CapReqBuilder(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
        builder.addAttribute(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, ee.getEEName());
        builder.setResource(framework);
        index.addCapability(builder.buildCapability());
    }
View Full Code Here

                Properties properties = new UTF8Properties();
                properties.load(stream);

                Parameters params = new Parameters(properties.getProperty("org.osgi.framework.system.packages", ""));
                for (String packageName : params.keySet()) {
                    CapReqBuilder builder = new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE);
                    builder.addAttribute(PackageNamespace.PACKAGE_NAMESPACE, packageName);
                    builder.addAttribute(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, new Version(0, 0, 0));
                    Capability cap = builder.setResource(framework).buildCapability();
                    capIndex.addCapability(cap);
                }
            } catch (IOException e) {
                throw new IllegalStateException("Error loading JRE package properties", e);
            }
View Full Code Here

TOP

Related Classes of aQute.bnd.osgi.resource.CapReqBuilder

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.