Package org.apache.ivy.osgi.core

Examples of org.apache.ivy.osgi.core.BundleInfo


    public void populate(Iterator<ManifestAndLocation> it) {
        while (it.hasNext()) {
            ManifestAndLocation manifestAndLocation = it.next();
            try {
                BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
                        .getManifest());
                bundleInfo
                        .addArtifact(new BundleArtifact(false, manifestAndLocation.getUri(), null));
                addBundle(bundleInfo);
            } catch (ParseException e) {
                Message.error("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage());
            }
View Full Code Here


                        return;
                    }
                    if (child.manifest != null) {
                        // Eclipse may have serialized a little bit weirdly
                        String manifest = ManifestParser.formatLines(child.manifest.trim());
                        BundleInfo embeddedInfo;
                        try {
                            embeddedInfo = ManifestParser.parseManifest(manifest);
                        } catch (IOException e) {
                            if (logLevel >= Message.MSG_VERBOSE) {
                                Message.verbose(
                                    "The Manifest of the source bundle "
                                            + bundleInfo.getSymbolicName() + " could not be parsed",
                                    e);
                            }
                            return;
                        } catch (ParseException e) {
                            if (logLevel >= Message.MSG_VERBOSE) {
                                Message.verbose(
                                    "The Manifest of the source bundle "
                                            + bundleInfo.getSymbolicName() + " is ill formed", e);
                            }
                            return;
                        }
                        if (!embeddedInfo.isSource()) {
                            if (logLevel >= Message.MSG_VERBOSE) {
                                Message.verbose("The Manifest of the source bundle "
                                        + bundleInfo.getSymbolicName()
                                        + " is not declaring being a source.");
                            }
                            return;
                        }
                        String symbolicNameTarget = embeddedInfo.getSymbolicNameTarget();
                        if (symbolicNameTarget == null) {
                            if (logLevel >= Message.MSG_VERBOSE) {
                                Message.verbose("The Manifest of the source bundle "
                                        + bundleInfo.getSymbolicName()
                                        + " is not declaring a target symbolic name.");
                            }
                            return;
                        }
                        Version versionTarget = embeddedInfo.getVersionTarget();
                        if (versionTarget == null) {
                            if (logLevel >= Message.MSG_VERBOSE) {
                                Message.verbose("The Manifest of the source bundle "
                                        + bundleInfo.getSymbolicName()
                                        + " is not declaring a target version.");
View Full Code Here

        protected void handleAttributes(Attributes atts) throws SAXException {
            String id = atts.getValue(ID);
            String version = atts.getValue(VERSION);
            // Boolean singleton = Boolean.valueOf(atts.getValue(SINGLETON));
            try {
                bundleInfo = new BundleInfo(id, new Version(version));
            } catch (ParseException e) {
                throw new SAXException("Incorrect version on bundle '" + id + "': " + version
                        + " (" + e.getMessage() + ")");
            }
        }
View Full Code Here

import org.apache.ivy.osgi.util.VersionRange;

public class PluginAdapter {

    public static BundleInfo featureAsBundle(URI baseUri, EclipseFeature feature) {
        BundleInfo b = new BundleInfo(feature.getId(), feature.getVersion());

        URI uri;
        if (feature.getUrl() == null) {
            uri = baseUri.resolve("features/" + feature.getId() + '_' + feature.getVersion()
                    + ".jar");
        } else {
            uri = baseUri.resolve(feature.getUrl());
        }
        b.addArtifact(new BundleArtifact(false, uri, null));

        b.setDescription(feature.getDescription());
        b.setLicense(feature.getLicense());

        for (EclipsePlugin plugin : feature.getPlugins()) {
            BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, plugin.getId(),
                    new VersionRange(plugin.getVersion()), null);
            b.addRequirement(r);
        }

        for (Require require : feature.getRequires()) {
            String id;
            if (require.getPlugin() != null) {
                id = require.getPlugin();
            } else {
                id = require.getFeature();
            }
            VersionRange range;
            if (require.getMatch().equals("greaterOrEqual")) {
                range = new VersionRange(require.getVersion());
            } else {
                throw new IllegalStateException("unsupported match " + require.getMatch());
            }
            BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, id, range, null);
            b.addRequirement(r);
        }

        return b;
    }
View Full Code Here

        return b;
    }

    public static BundleInfo pluginAsBundle(URI baseUri, EclipsePlugin plugin) {
        BundleInfo b = new BundleInfo(plugin.getId(), plugin.getVersion());

        URI uri = baseUri.resolve("plugins/" + plugin.getId() + '_' + plugin.getVersion() + ".jar");
        b.addArtifact(new BundleArtifact(false, uri, null));

        return b;
    }
View Full Code Here

    private IAccessRule[] getAccessRules(IPath artifact) {
        if (!osgiAvailable || !classpathSetup.isReadOSGiMetadata()) {
            return null;
        }
        BundleInfo bundleInfo;
        FileInputStream jar = null;
        try {
            jar = new FileInputStream(artifact.toFile());
            bundleInfo = ManifestParser.parseJarManifest(jar);
        } catch (IOException e) {
            IvyDEMessage.warn("OSGi metadata could not be extracted from " + artifact + ": "
                    + e.getMessage() + " (" + e.getClass().getName() + ")");
            return null;
        } catch (ParseException e) {
            IvyDEMessage.warn("OSGi metadata could not be extracted from " + artifact + ": "
                    + e.getMessage() + " (" + e.getClass().getName() + ")");
            return null;
        } finally {
            if (jar != null) {
                try {
                    jar.close();
                } catch (IOException e) {
                    // don't care
                }
            }
        }
        IAccessRule[] rules = new IAccessRule[bundleInfo.getExports().size() + 1];
        int i = 0;
        Iterator itExports = bundleInfo.getExports().iterator();
        while (itExports.hasNext()) {
            ExportPackage exportPackage = (ExportPackage) itExports.next();
            rules[i++] = JavaCore.newAccessRule(
                new Path(exportPackage.getName().replace('.', IPath.SEPARATOR) + "/*"),
                IAccessRule.K_ACCESSIBLE);
View Full Code Here

        public UnitsHandler() {
            super(UNITS);
            addChild(new UnitHandler(), new ChildElementHandler() {
                public void childHanlded(DelegetingHandler child) {
                    BundleInfo bundleInfo = ((UnitHandler) child).bundleInfo;
                    if (!bundleInfo.getCapabilities().isEmpty()) {
                        bundles.add(((UnitHandler) child).bundleInfo);
                    }
                }
            });
        }
View Full Code Here

        protected void handleAttributes(Attributes atts) throws SAXException {
            String id = atts.getValue(ID);
            String version = atts.getValue(VERSION);
            // Boolean singleton = Boolean.valueOf(atts.getValue(SINGLETON));
            try {
                bundleInfo = new BundleInfo(id, new Version(version));
            } catch (ParseException e) {
                throw new SAXException("Incorrect version on bundle '" + id + "': " + version
                        + " (" + e.getMessage() + ")");
            }
        }
View Full Code Here

            throw new BuildException("the manifest file '" + manifest + "' was not found", e);
        } catch (IOException e) {
            throw new BuildException("the manifest file '" + manifest + "' could not be read", e);
        }

        BundleInfo bundleInfo;
        try {
            bundleInfo = ManifestParser.parseManifest(m);
        } catch (ParseException e) {
            throw new BuildException("Incorrect manifest file '" + manifest + "'", e);
        }
View Full Code Here

                        + symbolicname + " is then ignored.");
                skip();
                return;
            }

            bundleInfo = new BundleInfo(symbolicname, version);
            bundleInfo.setPresentationName(atts.getValue(PRESENTATION_NAME));
            String uri = atts.getValue(URI);
            if (uri != null) {
                try {
                    bundleInfo.setUri(new URI(uri));
View Full Code Here

TOP

Related Classes of org.apache.ivy.osgi.core.BundleInfo

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.