Examples of Jar


Examples of aQute.bnd.osgi.Jar

        }
        return status;
    }

    private static void generateLauncherJar(ProjectLauncher launcher, File folder, MultiStatus status) {
        Jar launcherJar = new Jar("launch");

        // Merge in the classpath JARs
        Collection<String> classpath = launcher.getClasspath();
        for (String classpathEntry : classpath) {
            try {
                Jar classpathJar = new Jar(new File(classpathEntry));
                launcherJar.addAll(classpathJar);
            } catch (IOException e) {
                status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, String.format("Failed to add classpath JAR '%s'.", classpathEntry), e));
            }
        }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

    public List<File> getFiles() {
        return files;
    }

    void analyseFile(File file) {
        Jar jar = null;
        try {
            jar = new Jar(file);
            Attributes attribs = jar.getManifest().getMainAttributes();
            String bsn = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
            String version = attribs.getValue(Constants.BUNDLE_VERSION);

            bsnMap.put(file, Pair.newInstance(bsn, version));
        } catch (Exception e) {
            logger.logError("Error reading JAR file content", e);
        } finally {
            if (jar != null)
                jar.close();
        }
    }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

        return createStatus("Problem(s) preparing the runtime environment.", errors, warnings);
    }

    private static String validateClasspath(Collection<String> classpath) {
        for (String fileName : classpath) {
            Jar jar = null;
            try {
                jar = new Jar(new File(fileName));
                boolean frameworkExists = jar.exists("META-INF/services/" + FrameworkFactory.class.getName());
                if (frameworkExists)
                    return fileName;
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (jar != null) {
                    jar.close();
                }
            }
        }
        return null;
    }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

                getContainer().run(false, false, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        availablePackages.clear();
                        selectedPackages.clear();
                        for (IPath path : paths) {
                            Jar jar = null;
                            try {
                                if (path.isAbsolute())
                                    jar = new Jar(path.toFile());
                                else
                                    jar = new Jar(ResourcesPlugin.getWorkspace().getRoot().getLocation().append(path).toFile());

                                Map<String,Map<String,Resource>> dirs = jar.getDirectories();
                                for (Entry<String,Map<String,Resource>> entry : dirs.entrySet()) {
                                    if (entry.getValue() == null)
                                        continue;

                                    IPath packagePath = new Path(entry.getKey());
                                    if (packagePath.segmentCount() < 1)
                                        continue;
                                    if ("META-INF".equalsIgnoreCase(packagePath.segment(0)))
                                        continue;

                                    availablePackages.add(packagePath);
                                }
                            } catch (Exception e) {} finally {
                                if (jar != null)
                                    jar.close();
                            }
                        }
                    }
                });
            } catch (InvocationTargetException e) {
View Full Code Here

Examples of aQute.bnd.osgi.Jar

            return false;
        }

        // Compute the classpath to build the classloader.
        List<Jar> jars = analyzer.getClasspath();
        Jar jar = analyzer.getJar();

        Set<String> paths = new LinkedHashSet<String>();
        if (jar != null && jar.getSource() != null) {
            paths.add(jar.getSource().getAbsolutePath());
        }
        for (Jar j : jars) {
            if (j.getSource() != null) {
                paths.add(j.getSource().getAbsolutePath());
            }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

    public byte[] read(String path) throws IOException {

        // Find the resource either in the global jar or in one of the embed dependencies
        Resource resource = m_analyzer.getJar().getResource(path);
        if (resource == null) {
            Jar embed = findJar(path);
            if (embed == null) {
                throw new IOException(format("Cannot find resource %s in jar and classpath", path));
            }
            resource = embed.getResource(path);
        }
        InputStream is = null;
        try {
            is = resource.openInputStream();
        } catch (Exception e) {
View Full Code Here

Examples of aQute.bnd.osgi.Jar

            }

            if (m_includeEmbedComponents) {
                // Otherwise ...
                // Try to see if it is in an embed dependencies
                Jar jar = findJar(clazz.getAbsolutePath());
                if (jar == null) {
                    m_reporter.error("Resource for class %s not found in classpath", clazz.getFQN());
                    continue;
                }

                // Is it a Bundle ?
                if (jar.getBsn() != null) {
                    // OSGi Bundle case

                    // Check if the bundle was manipulated before
                    Attributes attr = jar.getManifest().getMainAttributes();
                    if (Manifests.getComponents(attr) != null) {
                        // Bundle has been previously manipulated
                        // TODO We should ignore the resource since it was already manipulated
                        // TODO But we should also merge its IPOJO-Components header
                    } else {
                        // Bundle was not manipulated
                        manipulable.add(clazz);
                    }

                } else  {
                    // Simple Jar file with iPOJO annotations
                    m_reporter.warning("Class %s found in a non-Bundle archive %s", clazz.getFQN(), jar.getName());
                    continue;
                }
            } else {
                m_reporter.warning("Embed components are excluded, Component %s will not be manipulated", clazz.getFQN());
            }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

        // IPOJO-Components will be written during the close method.
    }

    public void write(String resourcePath, byte[] resource) throws IOException {
        Jar jar = m_analyzer.getJar();
        jar.putResource(resourcePath, new ByteArrayResource(resource));
    }
View Full Code Here

Examples of aQute.bnd.osgi.Jar

        String bpHeader = analyzer.getProperty( "Bundle-Blueprint", "OSGI-INF/blueprint" );
        Map<String, ? extends Map<String, String>> map = Processor.parseHeader( bpHeader, null );
    bpHeader = "";
        for ( String root : map.keySet() )
        {
            Jar jar = analyzer.getJar();
            Map<String, Resource> dir = jar.getDirectories().get( root );
            if ( dir == null || dir.isEmpty() )
            {
                Resource resource = jar.getResource( root );
                if ( resource != null )
        {
                    process( analyzer, root, resource, headers );
          if (bpHeader.length() > 0) {
            bpHeader += ",";
View Full Code Here

Examples of aQute.bnd.osgi.Jar

            return;
        }

        // get the bundles that have to be compared

        final Jar currentBundle = getCurrentBundle();
        if ( currentBundle == null )
        {
            getLog().info( "Not generating Baseline report as there is no bundle generated by the project" );
            return;
        }

        final Jar previousBundle = getPreviousBundle();
        if ( previousBundle == null )
        {
            getLog().info( "Not generating Baseline report as there is no previous version of the library to compare against" );
            return;
        }
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.