An Ant task that injects elements necessary to run Cactus tests into an
existing WAR file.
| Method from org.apache.cactus.integration.ant.CactifyWarTask Detail: |
public final void addConfiguredEjbref(EjbRef theEjbRef) {
ejbRefs.add(theEjbRef);
}
Adds a configured EjbRef instance. Called by Ant. |
public final void addConfiguredXMLCatalog(XMLCatalog theXmlCatalog) {
if (this.xmlCatalog == null)
{
this.xmlCatalog = new XMLCatalog();
this.xmlCatalog.setProject(getProject());
}
this.xmlCatalog.addConfiguredXMLCatalog(theXmlCatalog);
}
Adds an XML catalog to the internal catalog. |
public final void addFilterRedirector(FilterRedirector theFilterRedirector) {
this.redirectors.add(theFilterRedirector);
}
Adds a Cactus filter test redirector. |
public final void addJspRedirector(JspRedirector theJspRedirector) {
this.redirectors.add(theJspRedirector);
}
Adds a Cactus JSP test redirector. |
public final void addServletRedirector(ServletRedirector theServletRedirector) {
this.redirectors.add(theServletRedirector);
}
Adds a Cactus servlet test redirector. |
public File createTempFile(String prefix,
String suffix,
File parentDir,
boolean deleteOnExit) {
File result = null;
String parent = (parentDir == null)
? System.getProperty("java.io.tmpdir")
: parentDir.getPath();
DecimalFormat fmt = new DecimalFormat("#####");
synchronized (rand) {
do {
result = new File(parent,
prefix + fmt.format(Math.abs(rand.nextInt()))
+ suffix);
} while (result.exists());
}
if (deleteOnExit) {
result.deleteOnExit();
}
return result;
}
|
public void execute() throws BuildException {
// Public Methods ----------------------------------------------------------
WebXml webXml = null;
if (this.srcFile != null)
{
log("Analyzing war: " + this.srcFile.getAbsolutePath(),
Project.MSG_INFO);
// Add everything that's in the source WAR to the destination WAR
ZipFileSet currentFiles = new ZipFileSet();
currentFiles.setSrc(this.srcFile);
currentFiles.createExclude().setName("WEB-INF/web.xml");
currentFiles.createExclude().setName("WEB-INF/weblogic.xml");
currentFiles.createExclude().setName("WEB-INF/orion-web.xml");
currentFiles.createExclude().setName("WEB-INF/ibm-web-bnd.xmi");
addZipfileset(currentFiles);
// Parse the original deployment descriptor
webXml = getOriginalWebXml();
}
if (this.srcFile == null || webXml == null)
{
if (this.version == null)
{
throw new BuildException("You need to specify either the "
+ "[srcfile] or the [version] attribute");
}
WebXmlVersion webXmlVersion = null;
if (this.version.equals("2.2"))
{
webXmlVersion = WebXmlVersion.V2_2;
}
else
{
webXmlVersion = WebXmlVersion.V2_3;
}
try
{
webXml = WebXmlIo.newWebXml(webXmlVersion);
}
catch (ParserConfigurationException pce)
{
throw new BuildException(
"Could not create deployment descriptor", pce);
}
}
File tmpWebXml = cactifyWebXml(webXml);
setWebxml(tmpWebXml);
addCactusJars();
try
{
super.execute();
}
finally
{
// Even though the temporary descriptor will get deleted
// automatically when the VM exits, delete it explicitly here just
// to be a better citizen
tmpWebXml.delete();
}
}
|
public final void setMergeWebXml(File theMergeFile) {
this.mergeWebXml = theMergeFile;
}
The descriptor to merge into the original file. |
public final void setSrcFile(File theSrcFile) {
this.srcFile = theSrcFile;
}
Sets the web application archive that should be cactified. |
public final void setVersion(Version theVersion) {
this.version = theVersion.getValue();
}
Sets the web-app version to use when creating a WAR file from scratch. |