|
|||||||||
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. |
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(XMLElement data)
Parse conditions and add them to the compiler. |
private void |
addCustomListeners(XMLElement data)
This method parses install.xml for defined listeners and put them in the right position. |
protected void |
addDynamicVariables(XMLElement data)
|
protected void |
addGUIPrefs(XMLElement data)
Returns the GUIPrefs. |
protected void |
addInfo(XMLElement data)
Builds the Info class from the XML tree. |
private void |
addInstallerRequirement(XMLElement data)
|
protected void |
addJars(XMLElement data)
Add project specific external jar files to the installer. |
protected void |
addLangpacks(XMLElement data)
Adds the ISO3 codes of the langpacks and associated resources. |
protected void |
addNativeLibraries(XMLElement data)
Add native libraries to the installer. |
protected void |
addPacks(XMLElement data)
Add packs and their contents to the installer. |
private void |
addPacksSingle(XMLElement data)
Add packs and their contents to the installer without checking the dependencies and includes. |
protected void |
addPanels(XMLElement 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(XMLElement data)
Adds the resources. |
protected void |
addVariables(XMLElement 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,
XMLElement parent)
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,
XMLElement parent)
Look for a project specified resources, which, if not absolute, are sought relative to the projects basedir. |
private java.util.Map |
getAdditionals(XMLElement f)
Calls the reviseAdditionalDataMap method of all registered CompilerListener's. |
Compiler |
getCompiler()
Access the install compiler |
private java.lang.Object[] |
getCompilerListenerInstance(XMLElement 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(XMLElement f)
|
PackagerListener |
getPackagerListener()
Retrieves the packager listener |
protected XMLElement |
getXMLTree()
Returns the XMLElement representing the installation XML file. |
private void |
loadPackagingInformation(XMLElement data)
|
static void |
main(java.lang.String[] args)
The main method if the compiler is invoked by a command-line call. |
private void |
notifyCompilerListener(java.lang.String callerName,
int state,
XMLElement data)
Calls all defined compile listeners notify method with the given data |
protected void |
parseError(java.lang.String message)
Create parse error with consistent messages. |
protected void |
parseError(XMLElement parent,
java.lang.String message)
Create parse error with consistent messages. |
protected void |
parseError(XMLElement parent,
java.lang.String message,
java.lang.Throwable cause)
Create a chained parse error with consistent messages. |
protected void |
parseWarn(XMLElement parent,
java.lang.String message)
Create a parse warning with consistent messages. |
protected java.lang.String |
requireAttribute(XMLElement element,
java.lang.String attribute)
Call getAttribute on an element, producing a meaningful error message if not present, or empty. |
protected XMLElement |
requireChildNamed(XMLElement parent,
java.lang.String name)
Call getFirstChildNamed on the parent, producing a meaningful error message on failure. |
protected java.lang.String |
requireContent(XMLElement element)
Call getContent on an element, producing a meaningful error message if not present, or empty. |
protected int |
requireIntAttribute(XMLElement element,
java.lang.String attribute)
Get a required attribute of an element, ensuring it is an integer. |
protected java.net.URL |
requireURLContent(XMLElement element)
Call getContent on an element, producing a meaningful error message if not present, or empty, or a valid URL. |
protected boolean |
requireYesNoAttribute(XMLElement 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(XMLElement element)
Perform recursive substitution on all properties |
protected void |
substituteProperties(XMLElement data)
Properties declaration is a fragment of the xml file. |
protected boolean |
validateYesNo(java.lang.String value)
|
protected boolean |
validateYesNoAttribute(XMLElement 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, 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 |
---|
clone, 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
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 directorypublic 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.Runnable
run
in class java.lang.Thread
public void executeCompiler() throws java.lang.Exception
java.lang.Exception
- Description of the Exceptionprivate void addInstallerRequirement(XMLElement data) throws CompilerException
CompilerException
private void loadPackagingInformation(XMLElement data) throws CompilerException
CompilerException
public boolean wasSuccessful()
protected void addGUIPrefs(XMLElement data) throws CompilerException
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void addJars(XMLElement data) throws java.lang.Exception
data
- The XML data.
java.lang.Exception
protected void addNativeLibraries(XMLElement data) throws java.lang.Exception
data
- The XML data.
java.lang.Exception
protected void addPacks(XMLElement data) throws CompilerException
data
- The XML data.
CompilerException
private void addPacksSingle(XMLElement data) throws CompilerException
data
- The XML data
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(XMLElement data) throws CompilerException
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void addResources(XMLElement data) throws CompilerException
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void addLangpacks(XMLElement data) throws CompilerException
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void addInfo(XMLElement data) throws java.lang.Exception
data
- The XML data. return The Info.
java.lang.Exception
- Description of the Exceptionprotected void addVariables(XMLElement data) throws CompilerException
<variables> <variable name="nom" value="value"/> <variable name="foo" value="pippo"/> </variables>variable declared in this can be referred to in parsable files.
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void addDynamicVariables(XMLElement data) throws CompilerException
CompilerException
protected void addConditions(XMLElement data) throws CompilerException
data
-
CompilerException
protected void substituteProperties(XMLElement data) throws CompilerException
<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>variable declared in this can be referred to in parsable files.
data
- The XML data.
CompilerException
- Description of the Exceptionprotected void substituteAllProperties(XMLElement 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 XMLElement getXMLTree() throws CompilerException, java.io.IOException
CompilerException
- For problems with the installation file
java.io.IOException
- for errors reading the installation fileprotected int getOverrideValue(XMLElement f) throws CompilerException
CompilerException
private java.net.URL findProjectResource(java.lang.String path, java.lang.String desc, XMLElement parent) throws CompilerException
path
- the relative path (using '/' as separator) to the resource.desc
- the description of the resource used to report errorsparent
- the XMLElement the resource is specified in, used to report errors
CompilerException
private java.net.URL findIzPackResource(java.lang.String path, java.lang.String desc, XMLElement parent) throws CompilerException
path
- the relative path (using '/' as separator) to the resource.desc
- the description of the resource used to report errorsparent
- the XMLElement the resource is specified in, used to report errors
CompilerException
protected void parseError(java.lang.String message) throws CompilerException
message
- Brief message explaining error
CompilerException
protected void parseError(XMLElement parent, java.lang.String message) throws CompilerException
parent
- The element in which the error occuredmessage
- Brief message explaining error
CompilerException
protected void parseError(XMLElement 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(XMLElement parent, java.lang.String message)
parent
- The element in which the warning occuredmessage
- Warning messageprotected XMLElement requireChildNamed(XMLElement 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(XMLElement element) throws CompilerException
element
- The element to get content of
CompilerException
protected java.lang.String requireContent(XMLElement element) throws CompilerException
element
- The element to get content of
CompilerException
protected boolean validateYesNo(java.lang.String value)
protected java.lang.String requireAttribute(XMLElement 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(XMLElement 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(XMLElement 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(XMLElement 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(XMLElement data) throws java.lang.Exception
data
- the XML data
java.lang.Exception
- Description of the Exceptionprivate 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(XMLElement var) throws java.lang.Exception
var
- the xml element of the "listener" node
java.lang.Exception
private void addCompilerListener(CompilerListener pe)
pe
- CompilerListener which should be addedprivate void notifyCompilerListener(java.lang.String callerName, int state, XMLElement data) throws CompilerException
callerName
- name of the calling method as stringstate
- CompileListener.BEGIN or ENDdata
- current install data
CompilerException
private java.util.Map getAdditionals(XMLElement f) throws CompilerException
f
- file releated XML node
CompilerException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |