org.codehaus.cargo.module.webapp.merge
Class MergedWarArchive

java.lang.Object
  extended by org.codehaus.cargo.module.webapp.merge.MergedWarArchive
All Implemented Interfaces:
JarArchive, WarArchive

public class MergedWarArchive
extends java.lang.Object
implements WarArchive

Subclass representing the merged WAR file.

Version:
$Id: MergedWarArchive.java 1705 2008-09-02 13:14:55Z adriana $

Method Summary
 void addProcessor(java.lang.String path, MergeProcessor merger)
           
 boolean containsClass(java.lang.String theClassName)
          Returns whether a class of the specified name is contained in the archive.
protected  void executeMergeProcessors(java.io.File assembleDir)
           
 void expandToPath(java.lang.String path)
          Expand the archive to the specified directory.
 void expandToPath(java.lang.String path, java.io.FileFilter filter)
          Expand the archive to the specified directory, filtering out files.
 java.lang.String findResource(java.lang.String theName)
          Returns the full path of a named resource in the archive.
protected  WarArchive firstWarFile()
           
 java.io.InputStream getResource(java.lang.String thePath)
          Returns a resource from the archive as input stream.
 java.util.List getResources(java.lang.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 mergeJarFiles(boolean mergeJarFiles)
          Control whether to also merge the JAR files.
 void store(java.io.File warFile)
          The actual merging takes place on the store() method, which writes combined archive out into the new location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

firstWarFile

protected WarArchive firstWarFile()
Returns:
the first war file in the merge list

addProcessor

public void addProcessor(java.lang.String path,
                         MergeProcessor merger)
Parameters:
path - in the path to merge to
merger - in the processor to add

getWebXmlMerger

public WebXmlMerger getWebXmlMerger()
                             throws java.io.IOException,
                                    org.jdom.JDOMException
Get the web XML merger.

Returns:
the WebXml merger
Throws:
java.io.IOException - on an IO Exception
org.jdom.JDOMException - on a XML Parse Exception

getWebXml

public WebXml getWebXml()
                 throws java.io.IOException,
                        org.jdom.JDOMException
Returns the deployment descriptor of the web application.

Specified by:
getWebXml in interface WarArchive
Returns:
The parsed deployment descriptor
Throws:
org.jdom.JDOMException
java.io.IOException - If there was a problem reading the deployment descriptor in the WAR
See Also:
WarArchive.getWebXml()

executeMergeProcessors

protected void executeMergeProcessors(java.io.File assembleDir)
                               throws MergeException,
                                      java.io.IOException
Parameters:
assembleDir - in the directory to output the merge data to
Throws:
MergeException - when there is a problem
java.io.IOException - if an IO exception

store

public void store(java.io.File warFile)
           throws MergeException,
                  java.io.IOException,
                  org.jdom.JDOMException
The actual merging takes place on the store() method, which writes combined archive out 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 interface WarArchive
Parameters:
warFile - file to store the war in.
Throws:
org.jdom.JDOMException
java.io.IOException - If there was a problem reading the deployment descriptor in the WAR
MergeException
See Also:
WarArchive.store(java.io.File)

containsClass

public boolean containsClass(java.lang.String theClassName)
                      throws java.io.IOException
Returns whether a class of the specified name is contained in the archive.

Specified by:
containsClass in interface JarArchive
Parameters:
theClassName - The name of the class to search for
Returns:
Whether the class was found
Throws:
java.io.IOException - If an I/O error occurred reading the archive
See Also:
JarArchive.containsClass(java.lang.String)

findResource

public java.lang.String findResource(java.lang.String theName)
                              throws java.io.IOException
Returns the full path of a named resource in the archive.

Specified by:
findResource in interface JarArchive
Parameters:
theName - The name of the resource
Returns:
The full path to the resource inside the archive
Throws:
java.io.IOException - If an I/O error occurred reading the archive
See Also:
JarArchive.findResource(java.lang.String)

getResource

public java.io.InputStream getResource(java.lang.String thePath)
                                throws java.io.IOException
Returns a resource from the archive as input stream.

Specified by:
getResource in interface JarArchive
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:
java.io.IOException - If an I/O error occurs
See Also:
JarArchive.getResource(java.lang.String)

getResources

public java.util.List getResources(java.lang.String thePath)
                            throws java.io.IOException
Returns the list of resources in the specified directory in the archive.

Specified by:
getResources in interface JarArchive
Parameters:
thePath - The directory
Returns:
The list of resources
Throws:
java.io.IOException - If an I/O error occurs
See Also:
JarArchive.getResources(java.lang.String)

expandToPath

public void expandToPath(java.lang.String path)
                  throws java.io.IOException
Expand the archive to the specified directory.

Specified by:
expandToPath in interface JarArchive
Parameters:
path - The path to expand to
Throws:
java.io.IOException - If an I/O error occurs
See Also:
JarArchive.expandToPath(String)

expandToPath

public void expandToPath(java.lang.String path,
                         java.io.FileFilter filter)
                  throws java.io.IOException
Expand the archive to the specified directory, filtering out files.

Specified by:
expandToPath in interface JarArchive
Parameters:
path - The path to expand to
filter - The filter to use
Throws:
java.io.IOException - If an I/O error occurs
See Also:
JarArchive.expandToPath(java.lang.String, java.io.FileFilter)

mergeJarFiles

public void mergeJarFiles(boolean mergeJarFiles)
Control whether to also merge the JAR files.

Parameters:
mergeJarFiles - true if we do (default)


Copyright © 2004-2011 Codehaus. All Rights Reserved.