|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
com.izforge.izpack.compiler.CompilerConfig
public class CompilerConfig
A parser for the installer xml configuration. This parses a document conforming to the installation.dtd and populates a Compiler instance to perform the install compilation.
| Nested Class Summary | |
|---|---|
private class |
CompilerConfig.Edge
This class is used for the classification of the edges |
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected java.lang.String |
basedir
The base directory. |
private Compiler |
compiler
The installer packager compiler |
protected java.util.List<CompilerListener> |
compilerListeners
List of CompilerListeners which should be called at packaging |
private java.lang.String |
filename
The xml install file |
private java.lang.String |
installText
The xml install configuration text |
private static java.lang.String |
IZ_TEST_FILE
|
private static java.lang.String |
IZ_TEST_SUBDIR
|
private static boolean |
NO
Constant for checking attributes. |
private java.util.HashMap<java.lang.String,java.util.List<java.net.URL>> |
packsLangUrlMap
A list of packsLang-files that were defined by the user in the resource-section The key of this map is an packsLang-file identifier, e.g. |
static java.lang.String |
STANDARD
Standard installer. |
static java.lang.String |
VERSION
The compiler version. |
static java.lang.String |
WEB
Web installer. |
private static boolean |
YES
Constant for checking attributes. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
CompilerConfig(java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
PackagerListener listener,
java.lang.String installText)
|
|
CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output)
The constructor. |
|
CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
PackagerListener listener)
The constructor. |
|
CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
int compr_level,
PackagerListener listener,
java.lang.String installText)
|
|
CompilerConfig(java.lang.String filename,
java.lang.String base,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
PackagerListener listener)
|
|
CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
PackagerListener listener,
java.lang.String installText)
|
|
| Method Summary | |
|---|---|
protected void |
addArchiveContent(java.io.File baseDir,
java.io.File archive,
java.lang.String targetdir,
java.util.List<OsConstraint> osList,
int override,
PackInfo pack,
java.util.Map additionals,
java.lang.String condition)
Add files in an archive to a pack |
private void |
addCompilerListener(CompilerListener pe)
Add a CompilerListener. |
protected void |
addConditions(IXMLElement data)
Parse conditions and add them to the compiler. |
private void |
addCustomListeners(IXMLElement data)
This method parses install.xml for defined listeners and put them in the right position. |
protected void |
addDynamicVariables(IXMLElement data)
|
protected void |
addGUIPrefs(IXMLElement data)
Returns the GUIPrefs. |
protected void |
addInfo(IXMLElement data)
Builds the Info class from the XML tree. |
private void |
addInstallerRequirement(IXMLElement data)
|
protected void |
addJars(IXMLElement data)
Add project specific external jar files to the installer. |
protected void |
addLangpacks(IXMLElement data)
Adds the ISO3 codes of the langpacks and associated resources. |
protected void |
addNativeLibraries(IXMLElement data)
Add native libraries to the installer. |
protected void |
addPacks(IXMLElement data)
Add packs and their contents to the installer. |
private void |
addPacksSingle(IXMLElement data)
Add packs and their contents to the installer without checking the dependencies and includes. |
private void |
addPanelActions(IXMLElement xmlPanel,
Panel panel)
|
protected void |
addPanels(IXMLElement data)
Parse panels and their paramters, locate the panels resources and add to the Packager. |
boolean |
addProperty(java.lang.String name,
java.lang.String value)
Add a name value pair to the project property set. |
protected void |
addRecursively(java.io.File baseDir,
java.io.File file,
java.lang.String targetdir,
java.util.List<OsConstraint> osList,
int override,
PackInfo pack,
java.util.Map additionals,
java.lang.String condition)
Recursive method to add files in a pack. |
protected void |
addResources(IXMLElement data)
Adds the resources. |
protected void |
addVariables(IXMLElement data)
Variable declaration is a fragment of the xml file. |
private void |
assertIsNormalReadableFile(java.io.File fileToCheck,
java.lang.String fileDescription)
Checks whether a File instance is a regular file, exists and is readable. |
private int |
checkBackEdges(java.util.Map<CompilerConfig.Edge,java.lang.Integer> edges)
This function checks for the existence of back edges. |
void |
checkDependencies(java.util.List<PackInfo> packs)
Checks whether the dependencies stated in the configuration file are correct. |
void |
compile()
Compile the installation |
private int |
dfs(java.util.List<PackInfo> packs,
java.util.Map<java.lang.String,PackInfo> names)
We use the dfs graph search algorithm to check whether the graph is acyclic as described in: Thomas H. |
private int |
dfsVisit(PackInfo u,
java.util.Map<java.lang.String,PackInfo> names,
java.util.Map<CompilerConfig.Edge,java.lang.Integer> edges)
|
void |
executeCompiler()
Compiles the installation. |
private java.net.URL |
findIzPackResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent)
|
private java.net.URL |
findIzPackResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent,
boolean ignoreWhenNotFound)
Look for an IzPack resource either in the compiler jar, or within IZPACK_HOME. |
private java.net.URL |
findProjectResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent)
Look for a project specified resources, which, if not absolute, are sought relative to the projects basedir. |
private java.util.Map |
getAdditionals(IXMLElement f)
Calls the reviseAdditionalDataMap method of all registered CompilerListener's. |
Compiler |
getCompiler()
Access the install compiler |
private java.lang.Object[] |
getCompilerListenerInstance(IXMLElement var)
Returns the compiler listener which is defined in the xml element. |
private java.util.List<java.lang.String> |
getContainedFilePaths(java.net.URL url)
Returns a list which contains the pathes of all files which are included in the given url. |
private java.lang.String |
getFullClassName(java.net.URL url,
java.lang.String className)
Returns the qualified class name for the given class. |
protected int |
getOverrideValue(IXMLElement f)
|
PackagerListener |
getPackagerListener()
Retrieves the packager listener |
protected IXMLElement |
getXMLTree()
Returns the IXMLElement representing the installation XML file. |
private void |
loadPackagingInformation(IXMLElement data)
|
static void |
main(java.lang.String[] args)
The main method if the compiler is invoked by a command-line call. |
private void |
mergePacksLangFiles()
A function to merge multiple packsLang-files into a single file for each identifier, e.g. |
private void |
notifyCompilerListener(java.lang.String callerName,
int state,
IXMLElement data)
Calls all defined compile listeners notify method with the given data |
protected void |
parseError(IXMLElement parent,
java.lang.String message)
Create parse error with consistent messages. |
protected void |
parseError(IXMLElement parent,
java.lang.String message,
java.lang.Throwable cause)
Create a chained parse error with consistent messages. |
protected void |
parseError(java.lang.String message)
Create parse error with consistent messages. |
protected void |
parseWarn(IXMLElement parent,
java.lang.String message)
Create a parse warning with consistent messages. |
private IXMLElement |
readRefPackData(java.lang.String refFileName,
boolean isselfcontained)
|
protected java.lang.String |
requireAttribute(IXMLElement element,
java.lang.String attribute)
Call getAttribute on an element, producing a meaningful error message if not present, or empty. |
protected IXMLElement |
requireChildNamed(IXMLElement parent,
java.lang.String name)
Call getFirstChildNamed on the parent, producing a meaningful error message on failure. |
protected java.lang.String |
requireContent(IXMLElement element)
Call getContent on an element, producing a meaningful error message if not present, or empty. |
protected int |
requireIntAttribute(IXMLElement element,
java.lang.String attribute)
Get a required attribute of an element, ensuring it is an integer. |
protected java.net.URL |
requireURLContent(IXMLElement element)
Call getContent on an element, producing a meaningful error message if not present, or empty, or a valid URL. |
protected boolean |
requireYesNoAttribute(IXMLElement element,
java.lang.String attribute)
Call getAttribute on an element, producing a meaningful error message if not present, or one of "yes" or "no". |
private static java.lang.String |
resolveIzPackHome(java.lang.String home)
|
void |
run()
The run() method. |
static void |
setIzpackHome(java.lang.String izHome)
Set the IzPack home directory |
protected void |
substituteAllProperties(IXMLElement element)
Perform recursive substitution on all properties |
protected void |
substituteProperties(IXMLElement data)
Properties declaration is a fragment of the xml file. |
protected boolean |
validateYesNo(java.lang.String value)
|
protected boolean |
validateYesNoAttribute(IXMLElement element,
java.lang.String attribute,
boolean defaultValue)
Call getAttribute on an element, producing a meaningful warning if not "yes" or "no". |
boolean |
wasSuccessful()
|
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String VERSION
public static final java.lang.String STANDARD
public static final java.lang.String WEB
private static boolean YES
private static boolean NO
private static final java.lang.String IZ_TEST_FILE
private static final java.lang.String IZ_TEST_SUBDIR
private java.lang.String filename
private java.lang.String installText
protected java.lang.String basedir
private Compiler compiler
protected java.util.List<CompilerListener> compilerListeners
private java.util.HashMap<java.lang.String,java.util.List<java.net.URL>> packsLangUrlMap
packsLang.xml_eng, the values
are lists of URL pointing to the concrete packsLang-files.
mergePacksLangFiles()| Constructor Detail |
|---|
public CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output)
throws CompilerException
filename - The XML filename.basedir - The base directory.kind - The installer kind.output - The installer filename.
CompilerException
public CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
PackagerListener listener)
throws CompilerException
filename - The XML filename.basedir - The base directory.kind - The installer kind.output - The installer filename.listener - The PackagerListener.
CompilerException
public CompilerConfig(java.lang.String filename,
java.lang.String base,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
PackagerListener listener)
throws CompilerException
filename - The XML filename.kind - The installer kind.output - The installer filename.compr_format - The compression format to be used for packs.listener - The PackagerListener.
CompilerException
public CompilerConfig(java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
PackagerListener listener,
java.lang.String installText)
throws CompilerException
basedir - The base directory.kind - The installer kind.output - The installer filename.listener - The PackagerListener.installText - The install xml configuration text
CompilerException
public CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
PackagerListener listener,
java.lang.String installText)
throws CompilerException
filename - The XML filename.basedir - The base directory.kind - The installer kind.output - The installer filename.compr_format - The compression format to be used for packs.listener - The PackagerListener.installText - The install xml configuration text
CompilerException
public CompilerConfig(java.lang.String filename,
java.lang.String basedir,
java.lang.String kind,
java.lang.String output,
java.lang.String compr_format,
int compr_level,
PackagerListener listener,
java.lang.String installText)
throws CompilerException
filename - The XML filename.basedir - The base directory.kind - The installer kind.output - The installer filename.compr_format - The compression format to be used for packs.compr_level - Compression level to be used if supported.listener - The PackagerListener.installText - The install xml configuration text
CompilerException| Method Detail |
|---|
public static void setIzpackHome(java.lang.String izHome)
izHome - - the izpack home directory
public boolean addProperty(java.lang.String name,
java.lang.String value)
name - the name of the propertyvalue - the value to set
public Compiler getCompiler()
public PackagerListener getPackagerListener()
public void compile()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
public void executeCompiler()
throws java.lang.Exception
java.lang.Exception - Description of the Exception
private void addInstallerRequirement(IXMLElement data)
throws CompilerException
CompilerException
private void loadPackagingInformation(IXMLElement data)
throws CompilerException
CompilerExceptionpublic boolean wasSuccessful()
protected void addGUIPrefs(IXMLElement data)
throws CompilerException
data - The XML data.
CompilerException - Description of the Exception
protected void addJars(IXMLElement data)
throws java.lang.Exception
data - The XML data.
java.lang.Exception
protected void addNativeLibraries(IXMLElement data)
throws java.lang.Exception
data - The XML data.
java.lang.Exception
protected void addPacks(IXMLElement data)
throws CompilerException
data - The XML data.
CompilerException
private void addPacksSingle(IXMLElement data)
throws CompilerException
data - The XML data
CompilerException
private IXMLElement readRefPackData(java.lang.String refFileName,
boolean isselfcontained)
throws CompilerException
CompilerException
public void checkDependencies(java.util.List<PackInfo> packs)
throws CompilerException
CompilerException
private int dfs(java.util.List<PackInfo> packs,
java.util.Map<java.lang.String,PackInfo> names)
packs - The graphnames - The name mapprivate int checkBackEdges(java.util.Map<CompilerConfig.Edge,java.lang.Integer> edges)
private int dfsVisit(PackInfo u,
java.util.Map<java.lang.String,PackInfo> names,
java.util.Map<CompilerConfig.Edge,java.lang.Integer> edges)
protected void addArchiveContent(java.io.File baseDir,
java.io.File archive,
java.lang.String targetdir,
java.util.List<OsConstraint> osList,
int override,
PackInfo pack,
java.util.Map additionals,
java.lang.String condition)
throws java.io.IOException
archive - the archive file to unpacktargetdir - the target directory where the content of the archive will be installedosList - The target OS constraints.override - Overriding behaviour.pack - Pack to be packed intoadditionals - Map which contains additional datacondition -
java.io.IOException
protected void addRecursively(java.io.File baseDir,
java.io.File file,
java.lang.String targetdir,
java.util.List<OsConstraint> osList,
int override,
PackInfo pack,
java.util.Map additionals,
java.lang.String condition)
throws java.io.IOException
file - The file to add.targetdir - The relative path to the parent.osList - The target OS constraints.override - Overriding behaviour.pack - Pack to be packed intoadditionals - Map which contains additional datacondition -
java.io.FileNotFoundException - if the file does not exist
java.io.IOException
protected void addPanels(IXMLElement data)
throws CompilerException
data - The XML data.
CompilerException - Description of the Exception
protected void addResources(IXMLElement data)
throws CompilerException
data - The XML data.
CompilerException - Description of the Exception
protected void addLangpacks(IXMLElement data)
throws CompilerException
data - The XML data.
CompilerException - Description of the Exception
protected void addInfo(IXMLElement data)
throws java.lang.Exception
data - The XML data. return The Info.
java.lang.Exception - Description of the Exception
protected void addVariables(IXMLElement data)
throws CompilerException
<p/>
<p/>
<p/>
<p/>
<variables>
<variable name="nom" value="value"/>
<variable name="foo" value="pippo"/>
</variables>
<p/>
<p/>
<p/>
<p/>
variable declared in this can be referred to in parsable files.
data - The XML data.
CompilerException - Description of the Exception
protected void addDynamicVariables(IXMLElement data)
throws CompilerException
CompilerException
protected void addConditions(IXMLElement data)
throws CompilerException
data -
CompilerException
protected void substituteProperties(IXMLElement data)
throws CompilerException
<p/>
<p/>
<p/>
<p/>
<properties>
<property name="app.name" value="Property Laden Installer"/>
<!-- Ant styles 'location' and 'refid' are not yet supported -->
<property file="filename-relative-to-install?"/>
<property file="filename-relative-to-install?" prefix="prefix"/>
<!-- Ant style 'url' and 'resource' are not yet supported -->
<property environment="prefix"/>
</properties>
<p/>
<p/>
<p/>
<p/>
variable declared in this can be referred to in parsable files.
data - The XML data.
CompilerException - Description of the Exception
protected void substituteAllProperties(IXMLElement element)
throws CompilerException
CompilerException
private void assertIsNormalReadableFile(java.io.File fileToCheck,
java.lang.String fileDescription)
throws CompilerException
CompilerException - if the file is either not existing, not a regular file or not
readable.
protected IXMLElement getXMLTree()
throws CompilerException,
java.io.IOException
CompilerException - For problems with the installation file
java.io.IOException - for errors reading the installation file
protected int getOverrideValue(IXMLElement f)
throws CompilerException
CompilerException
private java.net.URL findProjectResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent)
throws CompilerException
path - the relative path (using '/' as separator) to the resource.desc - the description of the resource used to report errorsparent - the IXMLElement the resource is specified in, used to report errors
CompilerException
private java.net.URL findIzPackResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent)
throws CompilerException
CompilerException
private java.net.URL findIzPackResource(java.lang.String path,
java.lang.String desc,
IXMLElement parent,
boolean ignoreWhenNotFound)
throws CompilerException
path - the relative path (using '/' as separator) to the resource.desc - the description of the resource used to report errorsparent - the IXMLElement the resource is specified in, used to report errorsignoreWhenNotFound - when false, throws a CompilerException indicating
fault in the parent element when resource not found.
CompilerException
protected void parseError(java.lang.String message)
throws CompilerException
message - Brief message explaining error
CompilerException
protected void parseError(IXMLElement parent,
java.lang.String message)
throws CompilerException
parent - The element in which the error occuredmessage - Brief message explaining error
CompilerException
protected void parseError(IXMLElement parent,
java.lang.String message,
java.lang.Throwable cause)
throws CompilerException
parent - The element in which the error occuredmessage - Brief message explaining error
CompilerException
protected void parseWarn(IXMLElement parent,
java.lang.String message)
parent - The element in which the warning occuredmessage - Warning message
protected IXMLElement requireChildNamed(IXMLElement parent,
java.lang.String name)
throws CompilerException
parent - The element to search for a childname - Name of the child element to get
CompilerException
protected java.net.URL requireURLContent(IXMLElement element)
throws CompilerException
element - The element to get content of
CompilerException
protected java.lang.String requireContent(IXMLElement element)
throws CompilerException
element - The element to get content of
CompilerExceptionprotected boolean validateYesNo(java.lang.String value)
protected java.lang.String requireAttribute(IXMLElement element,
java.lang.String attribute)
throws CompilerException
element - The element to get the attribute value ofattribute - The name of the attribute to get
CompilerException
protected int requireIntAttribute(IXMLElement element,
java.lang.String attribute)
throws CompilerException
element - The element to get the attribute value ofattribute - The name of the attribute to get
CompilerException
protected boolean requireYesNoAttribute(IXMLElement element,
java.lang.String attribute)
throws CompilerException
element - The element to get the attribute value ofattribute - The name of the attribute to get
CompilerException
protected boolean validateYesNoAttribute(IXMLElement element,
java.lang.String attribute,
boolean defaultValue)
element - The element to get the attribute value ofattribute - The name of the attribute to getdefaultValue - Value returned if attribute not present or invalidpublic static void main(java.lang.String[] args)
args - The arguments passed on the command-line.private static java.lang.String resolveIzPackHome(java.lang.String home)
private void addCustomListeners(IXMLElement data)
throws java.lang.Exception
data - the XML data
java.lang.Exception - Description of the Exception
private java.util.List<java.lang.String> getContainedFilePaths(java.net.URL url)
throws java.lang.Exception
url - url of the jar file
java.lang.Exception
private java.lang.String getFullClassName(java.net.URL url,
java.lang.String className)
throws java.io.IOException
url - url of the jar file which contains the classclassName - short name of the class for which the full name should be resolved
java.io.IOException
private java.lang.Object[] getCompilerListenerInstance(IXMLElement var)
throws java.lang.Exception
var - the xml element of the "listener" node
java.lang.Exceptionprivate void addCompilerListener(CompilerListener pe)
pe - CompilerListener which should be added
private void notifyCompilerListener(java.lang.String callerName,
int state,
IXMLElement data)
throws CompilerException
callerName - name of the calling method as stringstate - CompileListener.BEGIN or ENDdata - current install data
CompilerException
private java.util.Map getAdditionals(IXMLElement f)
throws CompilerException
f - file releated XML node
CompilerException
private void mergePacksLangFiles()
throws CompilerException
<res src="./packsLang01.xml" id="packsLang.xml"/>
<res src="./packsLang02.xml" id="packsLang.xml"/>
are merged into a single temp-file to act as if the user had defined:
<res src="/tmp/izpp47881.tmp" id="packsLang.xml"/>
CompilerException
private void addPanelActions(IXMLElement xmlPanel,
Panel panel)
throws CompilerException
xmlPanel - panel -
CompilerException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||