Package aQute.bnd.version

Examples of aQute.bnd.version.Version


public class BundleUtils {
    private static final String FILE_URL_PREFIX = "file:";

    public static final Bundle findBundle(BundleContext context, String symbolicName, VersionRange range) {
        Bundle matched = null;
        Version matchedVersion = null;
        Bundle[] bundles = context.getBundles();
        for (Bundle bundle : bundles) {
            try {
                String name = bundle.getSymbolicName();
                String versionStr = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
                Version version = versionStr != null ? new Version(versionStr) : new Version();
                if (range == null || range.includes(version)) {
                    if (symbolicName.equals(name)) {
                        if (matched == null || version.compareTo(matchedVersion) > 0) {
                            matched = bundle;
                            matchedVersion = version;
                        }
                    }
                }
View Full Code Here


                    continue;
                }
                if (repo instanceof WorkspaceRepository) {
                    continue;
                }
                File sourceBundle = repo.get(bsn + ".source", new Version(version), props);
                if (sourceBundle != null) {
                    return sourceBundle;
                }
            }
        } catch (final Exception e) {
View Full Code Here

    }

    public int compareTo(ExportedBundle other) {
        int diff = this.getSymbolicName().compareTo(other.getSymbolicName());
        if (diff == 0) {
            Version version1 = this.getVersion();
            if (version1 == null)
                version1 = new Version(0);
            Version version2 = other.getVersion();
            if (version2 == null)
                version2 = new Version(0);

            diff = version1.compareTo(version2);
        }
        return diff;
    }
View Full Code Here

public class BundleUtils {
    private static final String FILE_URL_PREFIX = "file:";

    public static final Bundle findBundle(BundleContext context, String symbolicName, VersionRange range) {
        Bundle matched = null;
        Version matchedVersion = null;
        Bundle[] bundles = context.getBundles();
        for (Bundle bundle : bundles) {
            try {
                String name = bundle.getSymbolicName();
                String versionStr = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
                Version version = versionStr != null ? new Version(versionStr) : new Version();
                if (range == null || range.includes(version)) {
                    if (symbolicName.equals(name)) {
                        if (matched == null || version.compareTo(matchedVersion) > 0) {
                            matched = bundle;
                            matchedVersion = version;
                        }
                    }
                }
View Full Code Here

        // Merge the bundle name + version
        String bsn = BundleUtils.getBundleSymbolicName(attribs);
        if (bsn != null) { // Ignore if not a bundle
            String versionStr = attribs.getValue(Constants.BUNDLE_VERSION);
            Version version = null;
            if (versionStr != null) {
                try {
                    version = new Version(versionStr);
                } catch (IllegalArgumentException e) {
                    logger.logError("Error parsing version of bundle: " + bsn, e);
                }
            }
            if (version == null)
                version = new Version(0);
            Set<Version> versions = bundleVersions.get(bsn);
            if (versions == null) {
                versions = new HashSet<Version>();
                bundleVersions.put(bsn, versions);
            }
View Full Code Here

            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;
                    }
                }
View Full Code Here

                    continue;
                }
                if (repo instanceof WorkspaceRepository) {
                    continue;
                }
                File sourceBundle = repo.get(bsn + ".source", new Version(version), null);
                if (sourceBundle != null) {
                    return sourceBundle;
                }
            }
        } catch (final Exception e) {
View Full Code Here

        IO.delete(putCheckoutDir);
    }

    public void testGitRepoGet() throws Exception {
        GitOBRRepo repo = getOBRRepo(getCheckoutDir);
        File bundleFile = repo.get("osgi.core", new Version("4.2.0"), null);
        assertNotNull("Repository returned null", bundleFile);
        assertEquals(IO.getFile(getCheckoutDir, "jars/osgi.core/osgi.core-4.2.0.jar").getAbsoluteFile(), bundleFile);
        removeOBRRepo();
    }
View Full Code Here

    }

    public void testGitRepoPut() throws Exception {
        GitOBRRepo repo = getOBRRepo(putCheckoutDir);
        repo.put(new BufferedInputStream(new FileInputStream(IO.getFile("testdata/eclipse2/ploogins/javax.servlet_2.5.0.v200806031605.jar"))), new RepositoryPlugin.PutOptions());
        File bundleFile = repo.get("javax.servlet", new Version("2.5"), null);
        assertNotNull("Repository returned null", bundleFile);
        assertEquals(IO.getFile(putCheckoutDir, "jars/javax.servlet/javax.servlet-2.5.0.jar"), bundleFile);
        removeOBRRepo();
    }
View Full Code Here

        });
    }

    private static Requirement createRequirement(Object elem) {
        String bsn = null;
        Version version = null;

        if (elem instanceof RepositoryBundle) {
            bsn = ((RepositoryBundle) elem).getBsn();
        } else if (elem instanceof RepositoryBundleVersion) {
            RepositoryBundleVersion rbv = (RepositoryBundleVersion) elem;
            bsn = rbv.getBundle().getBsn();
            version = rbv.getVersion();
        } else if (elem instanceof ProjectBundle) {
            bsn = ((ProjectBundle) elem).getBsn();
        }

        if (bsn != null) {
            Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bsn);
            if (version != null) {
                filter = new AndFilter().addChild(filter).addChild(new SimpleFilter("version", Operator.GreaterThanOrEqual, version.toString()));
            }
            Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
            return req;
        }
        return null;
View Full Code Here

TOP

Related Classes of aQute.bnd.version.Version

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.