com.izforge.izpack.compiler
Class Packager

java.lang.Object
  extended by com.izforge.izpack.compiler.PackagerBase
      extended by com.izforge.izpack.compiler.Packager
All Implemented Interfaces:
IPackager

public class Packager
extends PackagerBase

The packager class. The packager is used by the compiler to put files into an installer, and create the actual installer files.

Author:
Julien Ponge, Chadwick McHenry

Field Summary
private  JarOutputStream primaryJarStream
          Executable zipped output stream.
 
Fields inherited from class com.izforge.izpack.compiler.PackagerBase
alreadyWrittenFiles, baseFile, compressor, customDataList, dynamicvariables, guiPrefs, includedJarURLs, info, installerResourceURLMap, langpackNameList, listener, packJarsSeparate, packsList, panelList, rules, SKELETON_SUBPATH, variables
 
Constructor Summary
Packager()
          The constructor.
Packager(java.lang.String compr_format)
          Extended constructor.
Packager(java.lang.String compr_format, int compr_level)
          Extended constructor.
 
Method Summary
 void addConfigurationInformation(XMLElement data)
          Adds configuration information to the packager.
private  void copyZip(java.util.zip.ZipInputStream zin, org.apache.tools.zip.ZipOutputStream out)
          Copies contents of one jar to another.
private  void copyZip(java.util.zip.ZipInputStream zin, org.apache.tools.zip.ZipOutputStream out, java.util.List<java.lang.String> files)
          Copies specified contents of one jar to another.
private  java.util.jar.Pack200.Packer createAgressivePack200Packer()
           
 void createInstaller(java.io.File primaryFile)
          Create the installer, beginning with the specified jar.
private  JarOutputStream getJarOutputStream(java.lang.String name)
          Return a stream for the next jar.
private  boolean isNotSignedJar(java.io.File file)
           
protected  void writeIncludedJars()
          Copy included jars to primary jar.
protected  void writeInstallerObject(java.lang.String entryName, java.lang.Object object)
          Write an arbitrary object to primary jar.
protected  void writeInstallerResources()
          Write the data referenced by URL to primary jar.
protected  void writePacks()
          Write Packs to primary jar or each to a separate jar.
protected  void writeSkeletonInstaller()
          Write skeleton installer to primary jar.
 
Methods inherited from class com.izforge.izpack.compiler.PackagerBase
addCustomJar, addInstallerRequirements, addJarContent, addJarContent, addLangPack, addNativeLibrary, addNativeUninstallerLibrary, addPack, addPanelJar, addResource, getCompressor, getDynamicVariables, getPackagerListener, getPacksList, getRules, getVariables, initPackCompressor, sendMsg, sendMsg, sendStart, sendStop, setDynamicVariables, setGUIPrefs, setInfo, setPackagerListener, setRules, writeInstaller
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primaryJarStream

private JarOutputStream primaryJarStream
Executable zipped output stream. First to open, last to close. Attention! This is our own JarOutputStream, not the java standard!

Constructor Detail

Packager

public Packager()
         throws CompilerException
The constructor.

Throws:
CompilerException

Packager

public Packager(java.lang.String compr_format)
         throws CompilerException
Extended constructor.

Parameters:
compr_format - Compression format to be used for packs compression format (if supported)
Throws:
CompilerException

Packager

public Packager(java.lang.String compr_format,
                int compr_level)
         throws CompilerException
Extended constructor.

Parameters:
compr_format - Compression format to be used for packs
compr_level - Compression level to be used with the chosen compression format (if supported)
Throws:
CompilerException
Method Detail

createInstaller

public void createInstaller(java.io.File primaryFile)
                     throws java.lang.Exception
Description copied from interface: IPackager
Create the installer, beginning with the specified jar. If the name specified does not end in ".jar", it is appended. If secondary jars are created for packs (if the Info object added has a webDirURL set), they are created in the same directory, named sequentially by inserting ".pack#" (where '#' is the pack number) ".jar" suffix: e.g. "foo.pack1.jar". If any file exists, it is overwritten.

Throws:
java.lang.Exception

writeSkeletonInstaller

protected void writeSkeletonInstaller()
                               throws java.io.IOException
Write skeleton installer to primary jar. It is just an included jar, except that we copy the META-INF as well.

Specified by:
writeSkeletonInstaller in class PackagerBase
Throws:
java.io.IOException

writeInstallerObject

protected void writeInstallerObject(java.lang.String entryName,
                                    java.lang.Object object)
                             throws java.io.IOException
Write an arbitrary object to primary jar.

Specified by:
writeInstallerObject in class PackagerBase
Throws:
java.io.IOException

writeInstallerResources

protected void writeInstallerResources()
                                throws java.io.IOException
Write the data referenced by URL to primary jar.

Specified by:
writeInstallerResources in class PackagerBase
Throws:
java.io.IOException

writeIncludedJars

protected void writeIncludedJars()
                          throws java.io.IOException
Copy included jars to primary jar.

Specified by:
writeIncludedJars in class PackagerBase
Throws:
java.io.IOException

writePacks

protected void writePacks()
                   throws java.lang.Exception
Write Packs to primary jar or each to a separate jar.

Specified by:
writePacks in class PackagerBase
Throws:
java.lang.Exception

createAgressivePack200Packer

private java.util.jar.Pack200.Packer createAgressivePack200Packer()

isNotSignedJar

private boolean isNotSignedJar(java.io.File file)
                        throws java.io.IOException
Throws:
java.io.IOException

getJarOutputStream

private JarOutputStream getJarOutputStream(java.lang.String name)
                                    throws java.io.IOException
Return a stream for the next jar.

Throws:
java.io.IOException

copyZip

private void copyZip(java.util.zip.ZipInputStream zin,
                     org.apache.tools.zip.ZipOutputStream out)
              throws java.io.IOException
Copies contents of one jar to another.

TODO: it would be useful to be able to keep signature information from signed jar files, can we combine manifests and still have their content signed?

Throws:
java.io.IOException

copyZip

private void copyZip(java.util.zip.ZipInputStream zin,
                     org.apache.tools.zip.ZipOutputStream out,
                     java.util.List<java.lang.String> files)
              throws java.io.IOException
Copies specified contents of one jar to another.

TODO: it would be useful to be able to keep signature information from signed jar files, can we combine manifests and still have their content signed?

Throws:
java.io.IOException

addConfigurationInformation

public void addConfigurationInformation(XMLElement data)
Description copied from interface: IPackager
Adds configuration information to the packager.

Parameters:
data - - the xml-element packaging from the install.xml