Search in sources :

Example 6 with VersionRange

use of org.osgi.service.indexer.impl.types.VersionRange in project bnd by bndtools.

the class SCRAnalyzer method analyzeResource.

public void analyzeResource(Resource resource, List<Capability> caps, List<Requirement> reqs) throws Exception {
    String header = null;
    Manifest manifest = resource.getManifest();
    if (manifest != null)
        header = manifest.getMainAttributes().getValue(ComponentConstants.SERVICE_COMPONENT);
    if (header == null)
        return;
    StringTokenizer tokenizer = new StringTokenizer(header, ",");
    Version highest = null;
    while (tokenizer.hasMoreTokens()) {
        String pattern = tokenizer.nextToken().trim();
        List<String> paths = Util.findMatchingPaths(resource, pattern);
        if (paths != null)
            for (String path : paths) {
                Version version = processScrXml(resource, path, caps, reqs);
                if (version == null)
                    continue;
                if (highest == null || (version.compareTo(highest) > 0))
                    highest = version;
            }
    }
    if (highest != null) {
        Version lower = new Version(highest.getMajor(), highest.getMinor(), 0);
        Version upper = new Version(highest.getMajor() + 1, 0, 0);
        Requirement requirement = createRequirement(new VersionRange(true, lower, upper, false));
        reqs.add(requirement);
    }
}
Also used : Requirement(org.osgi.service.indexer.Requirement) StringTokenizer(java.util.StringTokenizer) Version(org.osgi.framework.Version) VersionRange(org.osgi.service.indexer.impl.types.VersionRange) Manifest(java.util.jar.Manifest)

Aggregations

VersionRange (org.osgi.service.indexer.impl.types.VersionRange)6 Map (java.util.Map)4 Manifest (java.util.jar.Manifest)4 Builder (org.osgi.service.indexer.Builder)4 Version (org.osgi.framework.Version)2 LinkedList (java.util.LinkedList)1 StringTokenizer (java.util.StringTokenizer)1 Requirement (org.osgi.service.indexer.Requirement)1