Package aQute.bnd.header

Examples of aQute.bnd.header.Parameters


            for (DependencyTree dependency : info.getBundles()) {
                if (dependency.isBundle()) {
                    // Expand the actual imports list with imports of our dependencies
                    String importPackages = dependency.getManifestEntry(Analyzer.IMPORT_PACKAGE);
                    if( notEmpty(importPackages) ) {
                        Parameters values = new Analyzer().parseHeader(importPackages);
                        for (Map.Entry<String, Attrs> entry : values.entrySet()) {
                            String res = entry.getValue().get("resolution:");
                            if( !"optional".equals(res) ) {
                                // add all the non-optional deps..
                                actualImports.add(entry.getKey());
                            }
View Full Code Here


    protected void importAllExportedPackages(DependencyTree dependencyTree) {
        try {
            String text = dependencyTree.getManifestEntry(ServiceConstants.INSTR_EXPORT_PACKAGE);
            if (text != null && text.length() > 0) {
                Parameters map = new Analyzer().parseHeader(text);
                for (Map.Entry<String, Attrs> entry : map.entrySet()) {
                    String key = entry.getKey();
                    Map<String, String> values = entry.getValue();
                    // TODO add optional resolution if this dependency is otional??

                    Map<String, String> current = importPackages.get(key);
View Full Code Here

            if (importPackage != null) {
                main.putValue(Analyzer.IMPORT_PACKAGE, importPackage);
            }

            String importPackages = emptyIfNull(main.getValue(Analyzer.IMPORT_PACKAGE));
            Parameters values = new Analyzer().parseHeader(importPackages);

            // add any missing version clauses
            if (versionResolver != null) {
                for (Map.Entry<String, Attrs> entry : values.entrySet()) {
                    String packageName = entry.getKey();
                    Map<String, String> packageValues = entry.getValue();
                    if (!packageValues.containsKey("version")) {
                        String version = versionResolver.resolvePackageVersion(packageName);
                        if (version != null) {
                            packageValues.put("version", version);
                        }
                    }
                }
            }

            // Merge in the extra imports - lets not add versions to extra imports as they come from exports which might not have versions.
            for (Map.Entry<String, Map<String, String>> entry : extraImportPackages.entrySet()) {
                Map<String, String> original = values.get(entry.getKey());
                if (original == null) {
                    original = entry.getValue();
                } else {
                    original.putAll(entry.getValue());
                }
                Attrs newAttrs = new Attrs();
                newAttrs.putAll(original);
                values.put(entry.getKey(), newAttrs);
            }

            // lets remove any excluded import packages
            String excludedPackagesText = main.getValue(ServiceConstants.INSTR_FAB_EXCLUDE_IMPORTS_PACKAGE);
            if (notEmpty(excludedPackagesText)) {
                StringTokenizer e = new StringTokenizer(excludedPackagesText);
                while (e.hasMoreTokens()) {
                    String expression = e.nextToken();
                    String ignore = expression;
                    if (ignore.endsWith("*")) {
                        do {
                            ignore = ignore.substring(0, ignore.length() - 1);
                        } while (ignore.endsWith("*"));

                        if (ignore.length() == 0) {
                            LOG.debug("Ignoring all imports due to %s value of %s", ServiceConstants.INSTR_FAB_EXCLUDE_IMPORTS_PACKAGE, expression);
                            values.clear();
                        } else {
                            List<String> packageNames = new ArrayList<String>(values.keySet());
                            for (String packageName : packageNames) {
                                if (packageName.equals(ignore) || packageName.startsWith(ignore)) {
                                    if (LOG.isDebugEnabled()) {
                                        LOG.debug("Ignoring package " + packageName + " due to " + ServiceConstants.INSTR_FAB_EXCLUDE_IMPORTS_PACKAGE + " value of " + expression);
                                    }
                                    values.remove(packageName);
                                }
                            }
                        }
                    } else {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Ignoring package " + ignore + " due to " + ServiceConstants.INSTR_FAB_EXCLUDE_IMPORTS_PACKAGE + " header");
                        }
                        values.remove(ignore);
                    }
                }
            }

            // lets remove optional dependency if they are exported from a non-optional dependency...
            for (Map.Entry<String, Attrs> entry : values.entrySet()) {
                String packageName = entry.getKey();
                Map<String, String> map = entry.getValue();
                String res = map.get("resolution:");
                if ("optional".equals(res)) {
                    if (!versionResolver.isPackageOptional(packageName)) {
                        map.remove("resolution:");
                        res = null;
                    }
                }
                if (!"optional".equals(res)) {
                    // add all the non-optional deps..
                    actualImports.add(packageName);
                }
            }

            // TODO do we really need to filter out any of the attribute values?
            // we were filtering out everything bar resolution:
            //importPackages  = Processor.printClauses(values, "resolution:");
            importPackages = Processor.printClauses(values /*, ALLOWED_PACKAGE_CLAUSES */);
            if (notEmpty(importPackages)) {
                main.putValue(Analyzer.IMPORT_PACKAGE, importPackages);
            }


            String exportPackages = emptyIfNull(main.getValue(Analyzer.EXPORT_PACKAGE));
            Parameters exports = new Analyzer().parseHeader(exportPackages);
            for (Map.Entry<String, Attrs> entry : exports.entrySet()) {
                String packageName = entry.getKey();
                Map<String, String> map = entry.getValue();
                String version = map.get("version");
                if (version == null) {
                    version = versionResolver.resolveExportPackageVersion(packageName);
View Full Code Here

        if (dependency != null) {
            // 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) {
                            version = map.get("specification-version");
                        }
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.