Examples of IBundleModelElement


Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

                "Should corresponding imports be removed?", getSection().getShell());

            // TODO should also prompt to remove corresponding imports from other
            // projects in workspace??
           
            IBundleModelElement info = getBundle().getBundleInfo();

            for (Iterator<IPackageExport> i = selection.iterator(); i.hasNext();)
            {
                IPackageExport pe = i.next();
                info.removeExport(pe);

                // Remove corresponding imports (maybe)
                if (shouldRemoveImports)
                {
                    for (IPackageImport pi : info.getImports())
                    {
                        if (pi.getPackageName().equals(pe.getPackageName()))
                        {
                            importsRemoved = true;
                            info.removeImport(pi);
                        }
                    }
                }
            }
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

     */
    public ISigilBundle getBundle(String id, IBldBundle bundle)
    {

        ISigilBundle sigilBundle = new SigilBundle();
        IBundleModelElement info = new BundleModelElement();
        sigilBundle.setBundleInfo(info);

        // exports
        // FIXME: UI doesn't understand export wildcard packages
        for (IPackageExport export : bundle.getExports())
        {
            IPackageExport clone = (IPackageExport) export.clone();
            clone.setParent(null);
            info.addExport(clone);
        }

        // imports
        for (IPackageImport import1 : bundle.getImports())
        {
            IPackageImport clone = (IPackageImport) import1.clone();
            clone.setParent(null);
            info.addImport(clone);
        }

        // requires
        for (IRequiredBundle require : bundle.getRequires())
        {
            IRequiredBundle clone = (IRequiredBundle) require.clone();
            clone.setParent(null);
            info.addRequiredBundle(clone);
        }

        // fragment
        IRequiredBundle fragment = bundle.getFragmentHost();
        if (fragment != null)
        {
            info.setFragmentHost(fragment);
        }

        // contents
        for (String pkg : bundle.getContents())
        {
            sigilBundle.addPackage(pkg);
        }

        // sources
        for (String source : config.getList(null, BldConfig.L_SRC_CONTENTS))
        {
            sigilBundle.addClasspathEntry(String.format(classpathFormat, "src", source));
        }

        // libs
        Map<String, Map<String, String>> libs = bundle.getLibs();

        for (String path : libs.keySet())
        {
            Map<String, String> attr = libs.get(path);
            String kind = attr.get(BldAttr.KIND_ATTRIBUTE);

            if ("classpath".equals(kind))
            {
                sigilBundle.addClasspathEntry(String.format(classpathFormat, "lib", path));
            }
            else
            {
                BldCore.error("Can't convert -libs kind=" + kind);
            }
        }

        // resources
        // FIXME: UI doesn't support -resources: path1=path2
        List<Resource> resources = bundle.getResources();
        for (Resource resource : resources)
        {
            sigilBundle.addSourcePath(resource);
        }

        ////////////////////
        // simple headers

        info.setSymbolicName(bundle.getSymbolicName());

        info.setVersion(VersionTable.getVersion(bundle.getVersion()));

        String activator = bundle.getActivator();
        if (activator != null)
            info.setActivator(activator);

        Properties headers = config.getProps(id, BldConfig.P_HEADER);
        String header;

        header = headers.getProperty("CATEGORY");
        if (header != null)
            info.setCategory(header);

        header = headers.getProperty(Constants.BUNDLE_CONTACTADDRESS);
        if (header != null)
            info.setContactAddress(header);

        header = headers.getProperty(Constants.BUNDLE_COPYRIGHT);
        if (header != null)
            info.setCopyright(header);

        header = headers.getProperty(Constants.BUNDLE_DESCRIPTION);
        if (header != null)
            info.setDescription(header);

        header = headers.getProperty(Constants.BUNDLE_VENDOR);
        if (header != null)
            info.setVendor(header);

        header = headers.getProperty(Constants.BUNDLE_NAME);
        if (header != null)
            info.setName(header);

        header = headers.getProperty(Constants.BUNDLE_DOCURL);
        if (header != null)
            info.setDocURI(URI.create(header));

        header = headers.getProperty(Constants.BUNDLE_LICENSE);
        if (header != null)
            info.setDocURI(URI.create(header));

        return sigilBundle;
    }
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

     * @param id
     * @param bundle
     */
    public void setBundle(String id, ISigilBundle bundle)
    {
        IBundleModelElement info = bundle.getBundleInfo();
        String bundleVersion = config.getString(id, BldConfig.S_VERSION);
        Map<String, Map<String, String>> exports = new TreeMap<String, Map<String, String>>();

        setSimpleHeaders(id, info);
        setExports(id, bundleVersion, info, exports);

        // -imports and -requires are global to all bundles
        setImports(null, bundleVersion, info, exports);
        setRequires(null, bundleVersion, info);

        setFragments(id, info);
        setContents(id, info, bundle);
        setLibraries(id, info, bundle);
        setResources(id, info, bundle);

        if (info.getSourceLocation() != null)
        {
            BldCore.error("SourceLocation conversion not yet implemented.");
        }

        if (!info.getLibraryImports().isEmpty())
        {
            BldCore.error("LibraryImports conversion not yet implemented.");
        }
    }
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

            in.close();
        }
    }
   
    public static IBundleModelElement buildBundleModelElement(ZipFile zip) throws IOException {
        IBundleModelElement info = null;

        Manifest mf = getManifest(zip);
       
        if (mf != null)
        {
            Attributes attrs = mf.getMainAttributes();
            String name = attrs.getValue("Bundle-SymbolicName");
            if (name == null)
            {
                // framework.jar doesn't have Bundle-SymbolicName!
                name = attrs.getValue("Bundle-Name");
            }

            if (name != null)
            {
                try
                {
                    info = ModelElementFactory.getInstance().newModelElement(
                        IBundleModelElement.class);
                    info.setSymbolicName(name.split(";")[0]);
                    info.setVersion(VersionTable.getVersion(attrs.getValue("Bundle-Version")));
                    info.setName(attrs.getValue("Bundle-Name"));
                    info.setDescription(attrs.getValue("Bundle-Description"));
                    info.setVendor(attrs.getValue("Bundle-Vendor"));

                    String str = attrs.getValue("Import-Package");
                    if (str != null)
                    {
                        addImports(info, str);
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

        if (bundle == null)
        {
            return null;
        }

        IBundleModelElement info = bundle.getBundleInfo();
        URI uri = info.getUpdateLocation();
        Resource res = null;

        try
        {
            URL url = (uri != null) ? uri.toURL() : bundle.getLocation().toURI().toURL();
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

    }

    private static Set<IPackageExport> mergeExports(ISigilBundle bundle,
        Set<ISigilBundle> all, List<IModelElement> requirements)
    {
        IBundleModelElement headers = bundle.getBundleInfo();
        // FIXME treeset as PackageExport does not implement equals/hashCode
        TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>(
            headers.getExports());
        IRequiredBundle host = headers.getFragmentHost();
        if (host != null)
        {
            for (ISigilBundle b : all)
            {
                if (host.accepts(b.getBundleCapability()))
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

        }
    }

    private ISigilBundle buildBundle(JarFile jar, File f) throws IOException
    {
        IBundleModelElement info = ManifestUtil.buildBundleModelElement(jar);

        ISigilBundle bundle = null;

        if (info != null)
        {
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

        URI uri = file.getCanonicalFile().toURI();
        IBldProject project = BldFactory.getProject(uri);

        for (IBldBundle bb : project.getBundles())
        {
            IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
                IBundleModelElement.class);

            for (IPackageExport pexport : bb.getExports())
            {
                info.addExport(pexport);
            }

            for (IPackageImport import1 : bb.getImports())
            {
                IPackageImport clone = (IPackageImport) import1.clone();
                clone.setParent(null);
                info.addImport(clone);
            }

            for (IRequiredBundle require : bb.getRequires())
            {
                IRequiredBundle clone = (IRequiredBundle) require.clone();
                clone.setParent(null);
                info.addRequiredBundle(clone);
            }

            info.setSymbolicName(bb.getSymbolicName());

            Version version = VersionTable.getVersion(bb.getVersion());
            info.setVersion(version);

            ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(
                ISigilBundle.class);
            pb.setBundleInfo(info);
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

            return bundle.getBundleInfo().getSymbolicName() + " "
                + bundle.getBundleInfo().getVersion();
        }
        if (element instanceof IBundleModelElement)
        {
            IBundleModelElement bundle = (IBundleModelElement) element;
            return bundle.getSymbolicName();
        }
        if (element instanceof IRequiredBundle)
        {
            IRequiredBundle req = (IRequiredBundle) element;
            return req.getSymbolicName() + " " + req.getVersions();
View Full Code Here

Examples of org.apache.felix.sigil.common.model.osgi.IBundleModelElement

            JarFile jar = null;

            try
            {
                final IBundleModelElement info;
                if (frameworkPath != null)
                {
                    systemBundle.setLocation(frameworkPath);
                    jar = new JarFile(frameworkPath,false);
                    info = ManifestUtil.buildBundleModelElement(jar);
                }
                else
                {
                    info = ModelElementFactory.getInstance().newModelElement(
                        IBundleModelElement.class);
                }

                info.setSymbolicName("system bundle");
                info.setName("Sigil system bundle");

                applyProfile(info);
                systemBundle.addChild(info);
            }
            catch (IOException e)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.