Examples of Manifest


Examples of java.util.jar.Manifest

          sb.append("knopflerfish-version: " + base + "\n");
          sb.append("jarunpacker-opendir: " + base + "\n");

          // Convert the string to a input stream
          InputStream is = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
          Manifest mf = new Manifest(is);

          out = new JarOutputStream(new FileOutputStream(file), mf);
        } else {
          out = new JarOutputStream(new FileOutputStream(file));
        }
View Full Code Here

Examples of java.util.jar.Manifest

    String wrapperJar;
    if ("App".equals(type))
       wrapperJar = getWrapperAppJar();
    else
      wrapperJar = getWrapperJar();
    Manifest manifest;
    try
    {
      manifest = new JarFile(wrapperJar).getManifest();
    }
    catch (IOException e1)
    {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      return null;
    }
    Attributes attr = manifest.getMainAttributes();

    String cl = attr.getValue("Class-Path-" + type);
    if (cl == null)
      return null;
View Full Code Here

Examples of java.util.jar.Manifest

        InputStream is = null;

        try
        {
            Manifest mf = null;
            if (manifest.getProtocol().equals("jar") || manifest.getProtocol().equals("zip") ||
                manifest.getProtocol().equals("wsjar"))
            {
                if (manifest.getPath().startsWith("http://"))
                {
                  // protocol formats:
                  //     jar:http:<path>!<manifest-file>, zip:http:<path>!<manifest-file>
                  // e.g jar:http://<host>[:port]/[app-path]/jpox-java5.jar!/plugin.xml
                  JarURLConnection jarConnection = (JarURLConnection) manifest.openConnection();
                  URL url = jarConnection.getJarFileURL();
                  mf = jarConnection.getManifest();
                  if (mf == null)
                  {
                      return null;
                  }
                  return registerBundle(mf, url);
                }
                else
                {
                    int begin = 4;
                    if (manifest.getProtocol().equals("wsjar"))
                    {
                        begin = 6;
                    }
                    // protocol formats:
                    //     jar:<path>!<manifest-file>, zip:<path>!<manifest-file>
                    //     jar:file:<path>!<manifest-file>, zip:file:<path>!<manifest-file>
                    String path = StringUtils.getDecodedStringFromURLString(manifest.toExternalForm());
                    int index = path.indexOf(JAR_SEPARATOR);
                    String jarPath = path.substring(begin, index);
                    if (jarPath.startsWith("file:"))
                    {
                        // remove "file:" from path, so we can use in File constructor
                        jarPath = jarPath.substring(5);
                    }
                    File jarFile = new File(jarPath);
                    mf = new JarFile(jarFile).getManifest();
                    if (mf == null)
                    {
                        return null;
                    }
                    return registerBundle(mf, jarFile.toURI().toURL());
                }
            }           
            else if (manifest.getProtocol().equals("rar") || manifest.getProtocol().equals("war"))
            {
                // protocol formats:
                //     rar:<rar-path>!<jar-path>!<manifest-file>, war:<war-path>!<jar-path>!<manifest-file>
                String path = StringUtils.getDecodedStringFromURLString(manifest.toExternalForm());
                int index = path.indexOf(JAR_SEPARATOR);
                String rarPath = path.substring(4, index);
                File file = new File(rarPath);
                URL rarUrl = file.toURI().toURL();
               
                String jarPath = path.substring(index+1, path.indexOf(JAR_SEPARATOR,index+1));
                JarFile rarFile = new JarFile(file);
                JarInputStream jis = new JarInputStream(rarFile.getInputStream(rarFile.getEntry(jarPath)));
                try
                {
                    mf = jis.getManifest();
                    if (mf == null)
                    {
                        return null;
                    }
                }
                finally
                {
                    jis.close();
                }
                return registerBundle(mf, rarUrl);
            }
            else if (manifest.getProtocol().equals("vfsfile") || manifest.getProtocol().equals("vfsjar") ||
                manifest.getProtocol().equals("vfszip") || manifest.getProtocol().equals("vfs") )
            {
                // protocol formats:
                // vfsfile:<path>!<manifest-file>, vfsjar:<path>!<manifest-file>, vfszip:<path>!<manifest-file>
                String path = StringUtils.getDecodedStringFromURLString(manifest.toExternalForm());
                int index = path.indexOf(JAR_SEPARATOR);
                if (index < 0)
                {
                    NucleusLogger.PLUGIN.warn("Unable to find jar bundle for " + path + " so ignoring");
                    return null;
                }
                else
                {
                    String jarPath = path.substring(0, index);
                    URL jarUrl = new URL(jarPath);

                    JarInputStream jis = null;
                    InputStream inputStream = jarUrl.openConnection().getInputStream();
                   
                    // JBoss 6 returns a JarInputStream instead of FileInputStream as previous versions
                    // which won't return the manifest below if we use it to construct a new JarInputStream,
                    // so we just use it.
                    if ( inputStream instanceof JarInputStream )
                    {
                      jis = (JarInputStream) inputStream;
                    }
                    else
                    {
                      jis = new JarInputStream(inputStream);
                    }
                   
                    try
                    {
                        mf = jis.getManifest();
                        if (mf == null)
                        {
                            return null;
                        }
                    }
                    finally
                    {
                        jis.close();
                    }
                    return registerBundle(mf, jarUrl);
                }
            }
            else
            {
                is = manifest.openStream();
                mf = new Manifest(is);
                return registerBundle(mf,manifest);
            }
        }
        catch (IOException e)
        {
View Full Code Here

Examples of java.util.jar.Manifest

    catch (MalformedURLException e2)
    {
      e2.printStackTrace();
      return null;
    }
    Manifest manifest;
    try
    {
      manifest = new JarFile(new File(jarName)).getManifest();
    }
    catch (IOException e1)
    {
      e1.printStackTrace();
      return null;
    }
    Attributes attr = manifest.getMainAttributes();

    String cl = attr.getValue("Class-Path");
    ClassLoader loader = null;
    if (cl != null)
    {
View Full Code Here

Examples of java.util.jar.Manifest

  protected void addClasspathFromManifest(ArrayList classpath, File f)
  {
    try
    {

      Manifest manifest = new JarFile(f).getManifest();
      Attributes attr = manifest.getMainAttributes();

      String cl = attr.getValue("Class-Path");
      if (cl == null)
        return;
      String[] clArr = cl.split(" ");
View Full Code Here

Examples of java.util.jar.Manifest

    if (manifest == null && shouldCreate) {
      String WEAVER_MANIFEST_VERSION = "1.0";
      Attributes.Name CREATED_BY = new Name("Created-By");
      String WEAVER_CREATED_BY = "AspectJ Compiler";

      manifest = new Manifest();

      Attributes attributes = manifest.getMainAttributes();
      attributes.put(Name.MANIFEST_VERSION, WEAVER_MANIFEST_VERSION);
      attributes.put(CREATED_BY, WEAVER_CREATED_BY);
    }
View Full Code Here

Examples of java.util.jar.Manifest

        runtime.getJRubyClassLoader().addURL(jarFile);

        try {
            JarInputStream in = new JarInputStream(new BufferedInputStream(jarFile.openStream()));

            Manifest mf = in.getManifest();
            if (mf != null) {
                String rubyInit = mf.getMainAttributes().getValue("Ruby-Init");
                if (rubyInit != null) {
                    JarEntry entry = in.getNextJarEntry();
                    while (entry != null && !entry.getName().equals(rubyInit)) {
                        entry = in.getNextJarEntry();
                    }
View Full Code Here

Examples of java.util.jar.Manifest

  /*
   * If we are writing to an output directory copy the manifest but only if we already have one
   */
  private void writeManifest() throws IOException {
    Manifest manifest = getWeaver().getManifest(false);
    if (manifest != null && zos == null) {
      File outputDir = buildConfig.getOutputDir();
      if (buildConfig.getCompilationResultDestinationManager() != null) {
        // Manifests are only written if we have a jar on the inpath. Therefore,
        // we write the manifest to the defaultOutputLocation because this is
        // where we sent the classes that were on the inpath
        outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
      }
      if (outputDir == null) {
        return;
      }
      File outputLocation = new File(outputDir, MANIFEST_NAME);
      OutputStream fos = FileUtil.makeOutputStream(outputLocation);
      manifest.write(fos);
      fos.close();
      if (buildConfig.getCompilationResultDestinationManager() != null) {
        buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
            CompilationResultDestinationManager.FILETYPE_RESOURCE);
      }
View Full Code Here

Examples of java.util.jar.Manifest

      // pr112830, allow variations on aspectjrt.jar of the form aspectjrtXXXXXX.jar
      if (p.isFile() && p.getName().startsWith("aspectjrt") && p.getName().endsWith(".jar")) {

        try {
          String version = null;
          Manifest manifest = new JarFile(p).getManifest();
          if (manifest == null) {
            ret = "no manifest found in " + p.getAbsolutePath() + ", expected " + Version.text;
            continue;
          }
          Attributes attr = manifest.getAttributes("org/aspectj/lang/");
          if (null != attr) {
            version = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
            if (null != version) {
              version = version.trim();
            }
View Full Code Here

Examples of java.util.jar.Manifest

    Path path = getRootDirectory().lookup("META-INF/MANIFEST.MF");
    if (path.canRead()) {
      ReadStream is = path.openRead();
     
      try {
        _manifest = new Manifest(is);
      } catch (IOException e) {
        log.warning(L.l("{0} Manifest file cannot be read for '{1}'.\n  {2}",
                        this, getRootDirectory(), e));

        log.log(Level.FINE, e.toString(), 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.