Package java.util.jar

Examples of java.util.jar.Manifest$WriteManifest


   
    // JarFile schliessen
    jar.close();
   
  // Manifest ermitteln
    Manifest manifest = readManifestFile(manifestFile);
    if ( manifest!=null ) {
      File file = new File(manifestFile);
      this.logln("\n adding existing manifest file "+file.getCanonicalPath());
   
    } else {
      this.logln("\n create new manifest");
      StringBuffer sbuf = new StringBuffer();
      sbuf.append("Manifest-Version: 1.0\n");
      sbuf.append("Created-By: "+System.getProperty("java.vm.version")+" ("+System.getProperty("java.vm.vendor")+")\n");
      sbuf.append("\n");
     
      // Den String in InputStream �berf�hren
      InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
     
      // Manifest erzeugen
      manifest = new Manifest(is);
    }
   
    // Zufallszahl als Teil des Namens f�r die tempor�re Datei
    String rand1 = String.valueOf(Math.random()).substring(2);
    String rand2 = String.valueOf(Math.random()).substring(2);
View Full Code Here


  public String getSVNVersion()  {
    String svnVersion ="";
    try {


      Manifest manifest = null;     
      String classContainer = getClass().getProtectionDomain().getCodeSource().getLocation().toString();     
      java.net.URL manifestUrl = new java.net.URL("jar:" + classContainer + "!/META-INF/MANIFEST.MF");
     
      if(classContainer.contains(".jar")) {
        manifest = new Manifest(manifestUrl.openStream());
      } else {
        manifest = new Manifest(new java.net.URL(classContainer + "/META-INF/MANIFEST.MF").openStream());
      }
      if(manifest != null) {
        java.util.jar.Attributes atr = manifest.getMainAttributes();
        Iterator it = atr.keySet().iterator();
        while(it.hasNext()) {   
          String key = it.next().toString();
          if(key.contains("Implementation-Version")){
            String value = atr.getValue(key);
View Full Code Here

        bn = fileName.substring(0, fileName.length() - 4);
      }

      final JarFile bundle = new JarFile(file);
      try {
        final Manifest manifest = bundle.getManifest();
        this.mainAttributes = manifest.getMainAttributes();
        this.manifestVersion = deriveBundleManifestVersion();
        this.bsn = deriveBundleSymbolicName();
        this.version = deriveBundleVersion();
        this.name = mainAttributes.getValue(Constants.BUNDLE_NAME);
View Full Code Here

      path = Util.replace(file.getCanonicalPath().substring(1 + baseDir.getCanonicalPath().length()), "\\", "/");
    }

    public void load() throws Exception {
      JarFile    jarFile      = new JarFile(file);
      Manifest   mf           = jarFile.getManifest();
      attribs                 = mf.getMainAttributes();

      pkgExportMap     = parseNames(attribs.getValue("Export-Package"));
      pkgImportMap     = parseNames(attribs.getValue("Import-Package"));

    }
View Full Code Here

          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

    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

        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

    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

  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

    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

TOP

Related Classes of java.util.jar.Manifest$WriteManifest

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.