com.izforge.izpack.compiler
Class PackagerBase

java.lang.Object
  extended by com.izforge.izpack.compiler.PackagerBase
All Implemented Interfaces:
IPackager
Direct Known Subclasses:
MultiVolumePackager, Packager

public abstract class PackagerBase
extends java.lang.Object
implements IPackager

The packager base class. The packager interface IPackager is used by the compiler to put files into an installer, and create the actual installer files. The packager implementation depends on different requirements (e.g. normal packager versus multi volume packager). This class implements the common used method which can also be overload as needed.

Author:
Klaus Bartz

Field Summary
protected  java.util.HashMap<java.io.FilterOutputStream,java.util.HashSet<java.lang.String>> alreadyWrittenFiles
          Files which are always written into the container file
protected  java.io.File baseFile
          Base file name of all jar files.
protected  PackCompressor compressor
          The compression format to be used for pack compression
protected  java.util.List<CustomData> customDataList
          The ordered custom actions informations.
protected  java.util.Map<java.lang.String,java.util.List<DynamicVariable>> dynamicvariables
          dynamic variables
protected  GUIPrefs guiPrefs
          Gui preferences of instatller.
protected  java.util.Set<java.lang.Object[]> includedJarURLs
          Jar file URLs who's contents will be copied into the installer.
protected  Info info
          Basic installer info.
private  java.util.List<InstallerRequirement> installerrequirements
           
protected  java.util.Map<java.lang.String,java.net.URL> installerResourceURLMap
          The langpack URLs keyed by locale name (e.g. de_CH).
protected  java.util.List<java.lang.String> langpackNameList
          The ordered langpack locale names.
protected  PackagerListener listener
          The listeners.
protected  boolean packJarsSeparate
          Each pack is created in a separte jar if webDirURL is non-null.
protected  java.util.List<PackInfo> packsList
          The ordered packs informations (as PackInfo objects).
protected  java.util.List<Panel> panelList
          The ordered panels informations.
protected  java.util.Map<java.lang.String,Condition> rules
          the conditions
static java.lang.String SKELETON_SUBPATH
          Path to the skeleton installer.
protected  java.util.Properties variables
          The variables used in the project
 
Constructor Summary
PackagerBase()
           
 
Method Summary
 void addCustomJar(CustomData ca, java.net.URL url)
          Add a custom data like custom actions, where order is important.
 void addInstallerRequirements(java.util.List<InstallerRequirement> conditions)
           
 void addJarContent(java.net.URL jarURL)
          Adds a jar file content to the installer.
 void addJarContent(java.net.URL jarURL, java.util.List<java.lang.String> files)
          Adds a jar file content to the installer.
 void addLangPack(java.lang.String iso3, java.net.URL xmlURL, java.net.URL flagURL)
          Adds a language pack.
 void addNativeLibrary(java.lang.String name, java.net.URL url)
          Adds a native library.
 void addNativeUninstallerLibrary(CustomData data)
          Marks a native library to be added to the uninstaller.
 void addPack(PackInfo pack)
          Adds a pack, order is mostly irrelevant.
 void addPanelJar(Panel panel, java.net.URL jarURL)
          Add a panel, where order is important.
 void addResource(java.lang.String resId, java.net.URL url)
          Adds a resource.
 PackCompressor getCompressor()
          Returns the current pack compressor
 java.util.Map<java.lang.String,java.util.List<DynamicVariable>> getDynamicVariables()
          Returns a map of dynamically refreshed variables
 PackagerListener getPackagerListener()
          Get the PackagerListener.
 java.util.List<PackInfo> getPacksList()
          Gets the packages list
 java.util.Map<java.lang.String,Condition> getRules()
           
 java.util.Properties getVariables()
          Allows access to add, remove and update the variables for the project, which are maintained in the packager.
 void initPackCompressor(java.lang.String compr_format, int compr_level)
          Initializes a pack compressor if supported by the packager
protected  void sendMsg(java.lang.String job)
          Dispatches a message to the listeners.
protected  void sendMsg(java.lang.String job, int priority)
          Dispatches a message to the listeners at specified priority.
protected  void sendStart()
          Dispatches a start event to the listeners.
protected  void sendStop()
          Dispatches a stop event to the listeners.
 void setDynamicVariables(java.util.Map<java.lang.String,java.util.List<DynamicVariable>> dynamicvariables)
           
 void setGUIPrefs(GUIPrefs prefs)
          Sets the GUI preferences.
 void setInfo(Info info)
          Sets the informations related to this installation.
 void setPackagerListener(PackagerListener listener)
          Adds a listener.
 void setRules(java.util.Map<java.lang.String,Condition> rules)
           
protected abstract  void writeIncludedJars()
           
protected  void writeInstaller()
           
protected abstract  void writeInstallerObject(java.lang.String entryName, java.lang.Object object)
           
protected abstract  void writeInstallerResources()
           
protected abstract  void writePacks()
           
protected abstract  void writeSkeletonInstaller()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.izforge.izpack.compiler.IPackager
addConfigurationInformation, createInstaller
 

Field Detail

SKELETON_SUBPATH

public static final java.lang.String SKELETON_SUBPATH
Path to the skeleton installer.

See Also:
Constant Field Values

baseFile

protected java.io.File baseFile
Base file name of all jar files. This has no ".jar" suffix.


info

protected Info info
Basic installer info.


guiPrefs

protected GUIPrefs guiPrefs
Gui preferences of instatller.


variables

protected java.util.Properties variables
The variables used in the project


panelList

protected java.util.List<Panel> panelList
The ordered panels informations.


packsList

protected java.util.List<PackInfo> packsList
The ordered packs informations (as PackInfo objects).


langpackNameList

protected java.util.List<java.lang.String> langpackNameList
The ordered langpack locale names.


customDataList

protected java.util.List<CustomData> customDataList
The ordered custom actions informations.


installerResourceURLMap

protected java.util.Map<java.lang.String,java.net.URL> installerResourceURLMap
The langpack URLs keyed by locale name (e.g. de_CH).


rules

protected java.util.Map<java.lang.String,Condition> rules
the conditions


dynamicvariables

protected java.util.Map<java.lang.String,java.util.List<DynamicVariable>> dynamicvariables
dynamic variables


includedJarURLs

protected java.util.Set<java.lang.Object[]> includedJarURLs
Jar file URLs who's contents will be copied into the installer.


packJarsSeparate

protected boolean packJarsSeparate
Each pack is created in a separte jar if webDirURL is non-null.


listener

protected PackagerListener listener
The listeners.


compressor

protected PackCompressor compressor
The compression format to be used for pack compression


alreadyWrittenFiles

protected java.util.HashMap<java.io.FilterOutputStream,java.util.HashSet<java.lang.String>> alreadyWrittenFiles
Files which are always written into the container file


installerrequirements

private java.util.List<InstallerRequirement> installerrequirements
Constructor Detail

PackagerBase

public PackagerBase()
Method Detail

sendMsg

protected void sendMsg(java.lang.String job)
Dispatches a message to the listeners.

Parameters:
job - The job description.

sendMsg

protected void sendMsg(java.lang.String job,
                       int priority)
Dispatches a message to the listeners at specified priority.

Parameters:
job - The job description.
priority - The message priority.

sendStart

protected void sendStart()
Dispatches a start event to the listeners.


sendStop

protected void sendStop()
Dispatches a stop event to the listeners.


addCustomJar

public void addCustomJar(CustomData ca,
                         java.net.URL url)
Description copied from interface: IPackager
Add a custom data like custom actions, where order is important. Only one copy of the class files neeed are inserted in the installer.

Specified by:
addCustomJar in interface IPackager
Parameters:
ca - custom action object
url - the URL to include once

addJarContent

public void addJarContent(java.net.URL jarURL)
Description copied from interface: IPackager
Adds a jar file content to the installer. Package structure is maintained. Need mechanism to copy over signed entry information.

Specified by:
addJarContent in interface IPackager
Parameters:
jarURL - The url of the jar to add to the installer. We use a URL so the jar may be nested within another.

addJarContent

public void addJarContent(java.net.URL jarURL,
                          java.util.List<java.lang.String> files)
Description copied from interface: IPackager
Adds a jar file content to the installer. Package structure is maintained. Need mechanism to copy over signed entry information. If the given file list is null the hole contents of the jar file will be copied else only the listed.

Specified by:
addJarContent in interface IPackager
Parameters:
jarURL - The url of the jar to add to the installer. We use a URL so the jar may be nested within another.
files - to be copied

addLangPack

public void addLangPack(java.lang.String iso3,
                        java.net.URL xmlURL,
                        java.net.URL flagURL)
Description copied from interface: IPackager
Adds a language pack.

Specified by:
addLangPack in interface IPackager
Parameters:
iso3 - The ISO3 code.
xmlURL - The location of the xml local info
flagURL - The location of the flag image resource

addNativeLibrary

public void addNativeLibrary(java.lang.String name,
                             java.net.URL url)
                      throws java.lang.Exception
Description copied from interface: IPackager
Adds a native library.

Specified by:
addNativeLibrary in interface IPackager
Parameters:
name - The native library name.
url - The url to get the data from.
Throws:
java.lang.Exception - Description of the Exception

addNativeUninstallerLibrary

public void addNativeUninstallerLibrary(CustomData data)
Description copied from interface: IPackager
Marks a native library to be added to the uninstaller.

Specified by:
addNativeUninstallerLibrary in interface IPackager
Parameters:
data - the describing custom action data object

addPack

public void addPack(PackInfo pack)
Description copied from interface: IPackager
Adds a pack, order is mostly irrelevant.

Specified by:
addPack in interface IPackager
Parameters:
pack - contains all the files and items that go with a pack

addPanelJar

public void addPanelJar(Panel panel,
                        java.net.URL jarURL)
Description copied from interface: IPackager
Add a panel, where order is important. Only one copy of the class files neeed are inserted in the installer.

Specified by:
addPanelJar in interface IPackager

addResource

public void addResource(java.lang.String resId,
                        java.net.URL url)
Description copied from interface: IPackager
Adds a resource.

Specified by:
addResource in interface IPackager
Parameters:
resId - The resource Id.
url - The location of the data

getCompressor

public PackCompressor getCompressor()
Description copied from interface: IPackager
Returns the current pack compressor

Specified by:
getCompressor in interface IPackager
Returns:
Returns the current pack compressor.

getPackagerListener

public PackagerListener getPackagerListener()
Description copied from interface: IPackager
Get the PackagerListener.

Specified by:
getPackagerListener in interface IPackager
Returns:
the current PackagerListener

getPacksList

public java.util.List<PackInfo> getPacksList()
Description copied from interface: IPackager
Gets the packages list

Specified by:
getPacksList in interface IPackager

getVariables

public java.util.Properties getVariables()
Description copied from interface: IPackager
Allows access to add, remove and update the variables for the project, which are maintained in the packager.

Specified by:
getVariables in interface IPackager
Returns:
map of variable names to values

initPackCompressor

public void initPackCompressor(java.lang.String compr_format,
                               int compr_level)
                        throws CompilerException
Description copied from interface: IPackager
Initializes a pack compressor if supported by the packager

Specified by:
initPackCompressor in interface IPackager
Throws:
CompilerException

setGUIPrefs

public void setGUIPrefs(GUIPrefs prefs)
Description copied from interface: IPackager
Sets the GUI preferences.

Specified by:
setGUIPrefs in interface IPackager
Parameters:
prefs - The new gUIPrefs value

setInfo

public void setInfo(Info info)
             throws java.lang.Exception
Description copied from interface: IPackager
Sets the informations related to this installation.

Specified by:
setInfo in interface IPackager
Parameters:
info - The info section.
Throws:
java.lang.Exception - Description of the Exception

setPackagerListener

public void setPackagerListener(PackagerListener listener)
Description copied from interface: IPackager
Adds a listener.

Specified by:
setPackagerListener in interface IPackager
Parameters:
listener - The listener.

getRules

public java.util.Map<java.lang.String,Condition> getRules()
Specified by:
getRules in interface IPackager
Returns:
the rules

setRules

public void setRules(java.util.Map<java.lang.String,Condition> rules)
Specified by:
setRules in interface IPackager
Parameters:
rules - the rules to set

writeInstaller

protected void writeInstaller()
                       throws java.lang.Exception
Throws:
java.lang.Exception

writeInstallerObject

protected abstract void writeInstallerObject(java.lang.String entryName,
                                             java.lang.Object object)
                                      throws java.io.IOException
Throws:
java.io.IOException

writeSkeletonInstaller

protected abstract void writeSkeletonInstaller()
                                        throws java.io.IOException
Throws:
java.io.IOException

writeInstallerResources

protected abstract void writeInstallerResources()
                                         throws java.io.IOException
Throws:
java.io.IOException

writeIncludedJars

protected abstract void writeIncludedJars()
                                   throws java.io.IOException
Throws:
java.io.IOException

writePacks

protected abstract void writePacks()
                            throws java.lang.Exception
Throws:
java.lang.Exception

getDynamicVariables

public java.util.Map<java.lang.String,java.util.List<DynamicVariable>> getDynamicVariables()
Description copied from interface: IPackager
Returns a map of dynamically refreshed variables

Specified by:
getDynamicVariables in interface IPackager
Returns:
the dynamicvariables

setDynamicVariables

public void setDynamicVariables(java.util.Map<java.lang.String,java.util.List<DynamicVariable>> dynamicvariables)
Specified by:
setDynamicVariables in interface IPackager
Parameters:
dynamicvariables - the dynamicvariables to set

addInstallerRequirements

public void addInstallerRequirements(java.util.List<InstallerRequirement> conditions)
Specified by:
addInstallerRequirements in interface IPackager