Class MergedWarArchive
- java.lang.Object
-
- org.codehaus.cargo.module.webapp.merge.MergedWarArchive
-
- All Implemented Interfaces:
JarArchive
,WarArchive
public class MergedWarArchive extends Object implements WarArchive
Subclass representing the merged WAR file.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProcessor(String path, MergeProcessor merger)
boolean
containsClass(String theClassName)
Returns whether a class of the specified name is contained in the archive.protected void
executeMergeProcessors(File assembleDir)
void
expandToPath(String path)
Expand the archive to the specified directory.String
findResource(String theName)
Returns the full path of a named resource in the archive.protected WarArchive
firstWarFile()
InputStream
getResource(String thePath)
Returns a resource from the archive as input stream.List<String>
getResources(String thePath)
Returns the list of resources in the specified directory in the archive.WebXml
getWebXml()
Returns the deployment descriptor of the web application.WebXmlMerger
getWebXmlMerger()
Get the web XML merger.void
merge(String assembleDir)
Here we write combined archive file structure out into the new location.void
mergeJarFiles(boolean mergeJarFiles)
Control whether to also merge the JAR files.void
store(File warFile)
Here we do actual merge and store resulting war file into the new location.
-
-
-
Method Detail
-
firstWarFile
protected WarArchive firstWarFile()
- Returns:
- the first war file in the merge list
-
addProcessor
public void addProcessor(String path, MergeProcessor merger)
- Parameters:
path
- in the path to merge tomerger
- in the processor to add
-
getWebXmlMerger
public WebXmlMerger getWebXmlMerger() throws IOException, org.jdom2.JDOMException
Get the web XML merger.- Returns:
- the WebXml merger
- Throws:
IOException
- on an IO Exceptionorg.jdom2.JDOMException
- on a XML Parse Exception
-
getWebXml
public WebXml getWebXml() throws IOException, org.jdom2.JDOMException
Returns the deployment descriptor of the web application.- Specified by:
getWebXml
in interfaceWarArchive
- Returns:
- The parsed deployment descriptor
- Throws:
IOException
- If there was a problem reading the deployment descriptor in the WARorg.jdom2.JDOMException
- If the deployment descriptor of the WAR could not be parsed
-
executeMergeProcessors
protected void executeMergeProcessors(File assembleDir) throws MergeException, IOException
- Parameters:
assembleDir
- in the directory to output the merge data to- Throws:
MergeException
- when there is a problemIOException
- if an IO exception
-
store
public void store(File warFile) throws MergeException, IOException, org.jdom2.JDOMException
Here we do actual merge and store resulting war file into the new location. Stores the war archive to file. Changes to the descriptors of the war archive will be stored as well.- Specified by:
store
in interfaceWarArchive
- Parameters:
warFile
- file to store the war in.- Throws:
IOException
- If there was a problem reading the deployment descriptor in the WARorg.jdom2.JDOMException
- If the deployment descriptor of the WAR could not be parsedMergeException
-
merge
public void merge(String assembleDir) throws MergeException, IOException, org.jdom2.JDOMException
Here we write combined archive file structure out into the new location.- Parameters:
assembleDir
- target directory to write to- Throws:
IOException
- If there was a problem reading the deployment descriptor in the WARorg.jdom2.JDOMException
- If the deployment descriptor of the WAR could not be parsedMergeException
- If one of merge processors fails
-
containsClass
public boolean containsClass(String theClassName) throws IOException
Returns whether a class of the specified name is contained in the archive.- Specified by:
containsClass
in interfaceJarArchive
- Parameters:
theClassName
- The name of the class to search for- Returns:
- Whether the class was found
- Throws:
IOException
- If an I/O error occurred reading the archive
-
findResource
public String findResource(String theName) throws IOException
Returns the full path of a named resource in the archive.- Specified by:
findResource
in interfaceJarArchive
- Parameters:
theName
- The name of the resource- Returns:
- The full path to the resource inside the archive
- Throws:
IOException
- If an I/O error occurred reading the archive
-
getResource
public InputStream getResource(String thePath) throws IOException
Returns a resource from the archive as input stream.- Specified by:
getResource
in interfaceJarArchive
- Parameters:
thePath
- The path to the resource in the archive- Returns:
- An input stream containing the specified resource, or
null
if the resource was not found in the JAR - Throws:
IOException
- If an I/O error occurs
-
getResources
public List<String> getResources(String thePath) throws IOException
Returns the list of resources in the specified directory in the archive.- Specified by:
getResources
in interfaceJarArchive
- Parameters:
thePath
- The directory- Returns:
- The list of resources
- Throws:
IOException
- If an I/O error occurs
-
expandToPath
public void expandToPath(String path) throws IOException
Expand the archive to the specified directory.- Specified by:
expandToPath
in interfaceJarArchive
- Parameters:
path
- The path to expand to- Throws:
IOException
- If an I/O error occurs
-
mergeJarFiles
public void mergeJarFiles(boolean mergeJarFiles)
Control whether to also merge the JAR files.- Parameters:
mergeJarFiles
- true if we do (default)
-
-