Package java.util.jar

Examples of java.util.jar.Manifest


         {
            type = J2eeModuleMetaData.CLIENT;
         }
         else if( mfFile != null )
         {
            Manifest mf = VFSUtils.readManifest(mfFile);
            Attributes attrs = mf.getMainAttributes();
            if( attrs.containsKey(Attributes.Name.MAIN_CLASS) )
            {
               type = J2eeModuleMetaData.CLIENT;
            }
            else
View Full Code Here


      {
         return null;
      }

      InputStream is = mfURL.openStream();
      Manifest mf;
      try
      {
         mf = new Manifest(is);
      }
      finally
      {
         is.close();
      }
      Attributes attrs = mf.getMainAttributes();
      String mainClassName = attrs.getValue(Attributes.Name.MAIN_CLASS);        
      return mainClassName;
   }
View Full Code Here

      JarInputStream jis = new JarInputStream(moduleArchive);

      // make sure we don't loose the manifest when creating a new JarOutputStream
      JarOutputStream jos = null;
      FileOutputStream fos = new FileOutputStream(tmpFile);
      Manifest manifest = jis.getManifest();
      if (manifest != null)
         jos = new JarOutputStream(fos, manifest);
      else jos = new JarOutputStream(fos);

      // process all modules
View Full Code Here

      JarInputStream jisModule = new JarInputStream(new FileInputStream(tmpModule));
      File tmpJBossModule = getTempFile("jboss_" + entryName);
      tmpFiles.add(tmpJBossModule);
      JarOutputStream jos = null;
      fos = new FileOutputStream(tmpJBossModule);
      Manifest manifest = jisModule.getManifest();
      if (manifest != null)
         jos = new JarOutputStream(fos, manifest);
      else jos = new JarOutputStream(fos);

      // now copy entry by entry
View Full Code Here

         {
            type = J2eeModuleMetaData.CLIENT;
         }
         else if( mfFile != null )
         {
            Manifest mf = VFSUtils.readManifest(mfFile);
            Attributes attrs = mf.getMainAttributes();
            if( attrs.containsKey(Attributes.Name.MAIN_CLASS) )
            {
               type = J2eeModuleMetaData.CLIENT;
            }
            else
View Full Code Here

         {
            tmpFile.renameTo(file);
            throw new FileNotFoundException("Not a JarFile: "+file);
         }

         Manifest tmpMf = jarFile.getManifest();
         this.mf = tmpMf == null ? new Manifest() : tmpMf;
         Attributes mfAttrs = mf.getMainAttributes();

         String sealedAttr = mfAttrs.getValue(Attributes.Name.SEALED);
         sealed = Boolean.valueOf(sealedAttr).booleanValue();
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);
                mf = new JarInputStream(rarFile.getInputStream(rarFile.getEntry(jarPath))).getManifest();
                if (mf == null)
                {
                    return null;
                }
                return registerBundle(mf, rarUrl);
            }
            else
            {
                is = manifest.openStream();
                mf = new Manifest(is);
                return registerBundle(mf,manifest);
            }
        }
        catch (IOException e)
        {
View Full Code Here

    }
  }
 
  private void createManifestFile(ArrayList iSecName, ArrayList iSecOrigin, ArrayList iSecDate, String targetPath) throws IOException, Exception {
   
    Manifest manifest = null;
    File file = null;
   
    try {
     
      if (iSecName==null || iSecOrigin==null || iSecDate==null)
        throw new Exception("iSec is null");
      if ( !((iSecName.size()==iSecOrigin.size()) && (iSecName.size()==iSecDate.size())) )
        throw new Exception("iSec ArrayList sizes are inconsistent "+iSecName.size()+","+iSecOrigin.size()+","+iSecDate.size());
     
    // Falls keine Klasse entpackt wurde, soll auch kein Manifest geschrieben werden
      if ( iSecName.size()==0 ) return;
     
      if ( targetPath==null ) targetPath = "";
     
      file = new File(targetPath + "META-INF");
      if ( !file.isDirectory() )
        file.mkdir();
     
      file = new File(targetPath + "META-INF/MANIFEST.MF");
      file.createNewFile();
     
      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");
     
      for (int i=0; i<iSecName.size(); i++) {
        sbuf.append("Name: "+ (String)iSecName.get(i) +"\n");
        sbuf.append("Origin: "+ (String)iSecOrigin.get(i) +"\n");
        sbuf.append("Archive-Date: "+ (String)iSecDate.get(i) +"\n");
        sbuf.append("\n");
      }
     
      // Convert the string to a input stream
      InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
     
      // Create the manifest
      manifest = new Manifest(is);
      manifest.write(new FileOutputStream(file));
     
      this.logln("\n manifest file "+ file.getCanonicalPath() +" created");
     
    } catch (IOException iox) {
      throw new IOException(this.identity+"constructManifest: "+iox.getMessage());
View Full Code Here

    }
  }
 
  private Manifest readManifestFile(String path) throws IOException {
   
    Manifest manifest = null;
   
    if ( path==null ) return null;
   
    File file = new File(path);
   
    if ( file.canRead() ) {
     
      try {
        manifest = new Manifest(new FileInputStream(file));
      } catch (FileNotFoundException nfx) {
      } catch (IOException iox) {
        throw new IOException(this.identity+"readManifestFile: "+file.getCanonicalPath()+": "+iox.getMessage());
      }
    }
View Full Code Here

      byte buffer[] = new byte[BUFFER_SIZE];
     
      // Archiv �ffnen
      FileOutputStream stream = new FileOutputStream(jarFile);
     
      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);
      }
     
      JarOutputStream out = new JarOutputStream(stream, manifest);
     
      if ( this.compression != -1)
View Full Code Here

TOP

Related Classes of java.util.jar.Manifest

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.