Package aQute.bnd.header

Examples of aQute.bnd.header.Parameters


        if (manifest == null)
            return;

        Attributes attribs = manifest.getMainAttributes();
        String exportPkgStr = attribs.getValue(Constants.EXPORT_PACKAGE);
        Parameters exportsMap = new Parameters(exportPkgStr);

        // Merge the exports
        Map<PackageRef,List<PackageRef>> uses = builder.getUses();
        for (Entry<String,Attrs> entry : exportsMap.entrySet()) {
            String pkgName = Processor.removeDuplicateMarker(entry.getKey());
            ExportPackage export = new ExportPackage(pkgName, entry.getValue(), uses.get(pkgName));
            List<ExportPackage> exportList = exports.get(export.getName());
            if (exportList == null) {
                exportList = new LinkedList<ExportPackage>();
View Full Code Here


            return;
        Attributes attribs = manifest.getMainAttributes();

        // Process imports
        String importPkgStr = attribs.getValue(Constants.IMPORT_PACKAGE);
        Parameters importsMap = new Parameters(importPkgStr);
        for (Entry<String,Attrs> entry : importsMap.entrySet()) {
            String pkgName = entry.getKey();
            Attrs importAttribs = entry.getValue();

            // Calculate the importing classes for this import
            Map<String,List<Clazz>> classMap = new HashMap<String,List<Clazz>>();
            Collection<Clazz> classes = Collections.emptyList();
            try {
                classes = builder.getClasses("", "IMPORTING", pkgName);
            } catch (Exception e) {
                logger.logError("Error querying importing classes.", e);
            }
            for (Clazz clazz : classes) {
                String fqn = clazz.getFQN();
                int index = fqn.lastIndexOf('.');
                if (index < 0)
                    continue;
                String pkg = fqn.substring(0, index);

                List<Clazz> list = classMap.get(pkg);
                if (list == null) {
                    list = new LinkedList<Clazz>();
                    classMap.put(pkg, list);
                }
                list.add(clazz);
            }

            // Check if this is a self-import
            boolean selfImport = false;
            List<ExportPackage> matchingExports = exports.get(pkgName);
            if (matchingExports != null) {
                String versionRangeStr = importAttribs.get(Constants.VERSION_ATTRIBUTE);
                VersionRange versionRange = (versionRangeStr != null) ? new VersionRange(versionRangeStr) : new VersionRange("0");
                for (ExportPackage export : matchingExports) {
                    String versionStr = export.getAttribs().get(Constants.VERSION_ATTRIBUTE);
                    Version version = (versionStr != null) ? new Version(versionStr) : new Version(0);
                    if (versionRange.includes(version)) {
                        selfImport = true;
                        break;
                    }
                }
            }
            ImportPackage importPackage = new ImportPackage(pkgName, selfImport, importAttribs, usedBy.get(pkgName), classMap);
            List<ImportPackage> importList = imports.get(pkgName);
            if (importList == null) {
                importList = new LinkedList<ImportPackage>();
                imports.put(pkgName, importList);
            }
            importList.add(importPackage);
        }

        // Process require-bundles
        String requireBundlesStr = attribs.getValue(Constants.REQUIRE_BUNDLE);
        final Parameters requiredBundleMap = new Parameters(requireBundlesStr);
        for (Entry<String,Attrs> entry : requiredBundleMap.entrySet()) {
            String name = entry.getKey();
            Attrs rbAttribs = entry.getValue();

            // Check if the required bundle is already included in the closure
            boolean satisfied = false;
View Full Code Here

        if (stream != null) {
            try {
                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);
View Full Code Here

        if (stream != null) {
            try {
                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);
View Full Code Here

      String value = additionalPropertiesAsMap.get(key);
      if (key.equals(INCLUDE_RESOURCE)) {
        // there are paths in there, collapse these so the IML files don't get mixed up on every machine. The built in macro manager
        // does not recognize these, so we have to do this manually here.
        Parameters parameters = OSGiHeader.parseHeader(value);

        for (String name : parameters.keySet()) {
          if (StringUtil.startsWithChar(name, '{') && name.endsWith("}")) {
            name = name.substring(1, name.length() - 1).trim();
          }

          String[] parts = name.split("\\s*=\\s*");
 
View Full Code Here

    }
  }


  protected final void processInstructions(String header) throws DependencyEmbedderException {
    Parameters instructions = OSGiHeader.parseHeader(MISSING_KEY_PATTERN.matcher(header).replaceAll("$1$2*;$3"));

    Collection<MavenArtifact> availableDependencies = new LinkedHashSet<MavenArtifact>(m_dependencyArtifacts);

    DependencyFilter filter;
    for (Iterator<Map.Entry<String, Attrs>> clauseIterator = instructions.entrySet().iterator(); clauseIterator.hasNext(); ) {
      String inline = "false";

      // always start with a fresh *modifiable* collection for each unique clause
      Collection<MavenArtifact> filteredDependencies = new LinkedHashSet<MavenArtifact>(availableDependencies);

View Full Code Here

    String includeResourceHeader = props.get(Constants.INCLUDE_RESOURCE);
    if (StringUtil.isEmpty(includeResourceHeader)) {
      return;
    }

    Parameters parameters = OSGiHeader.parseHeader(includeResourceHeader);
    StringBuilder sanitizedHeader = new StringBuilder();
    for (Iterator<String> iterator = parameters.keySet().iterator(); iterator.hasNext(); ) {
      String name = iterator.next();
      String prefix = "";
      String suffix = "";
      if (StringUtil.startsWithChar(name, '{') && name.endsWith("}")) {
        name = name.substring(1, name.length() - 1).trim();
View Full Code Here

            if (rc.isEmpty()) {
                break;
            }
            String value = (String) bundle.getHeaders().get("Export-Package");
            if (Strings.notEmpty(value)) {
                Parameters values = new Analyzer().parseHeader(value);
                for (String packageName : packages) {
                    Map<String, String> map = values.get(packageName);
                    if (map != null) {
                        String version = map.get("version");
                        if (version != null) {
                            String importedVersion = resolver.resolvePackageVersion(packageName);
                            if (importedVersion != null) {
View Full Code Here

    public static String getOSGiPackageVersion(DependencyTree dependency, String packageName) {
        // lets find the export packages and use the version from that
        if (dependency.isBundle()) {
            String exportPackages = dependency.getManifestEntry("Export-Package");
            if (notEmpty(exportPackages)) {
                Parameters values = new Analyzer().parseHeader(exportPackages);
                Map<String, String> map = values.get(packageName);
                if (map != null) {
                    String version = map.get("version");
                    if (version != null) {
                        return version;
                    }
View Full Code Here

        return types;
    }

    protected void process(List<XMLType> types, String resource, String paths, String pattern) throws Exception {
        Parameters map = Processor.parseHeader(paths, null);
        for ( String path : map.keySet() ) {
            types.add( new ClassPathImportsXmlType( getClass().getResource(resource), path, pattern ));
        }
    }
View Full Code Here

TOP

Related Classes of aQute.bnd.header.Parameters

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.