vmassol 2004/01/10 12:57:16
Modified: integration/ant/src/java/org/apache/cactus/integration/ant/container
DeployableFile.java WarDeployableFile.java
EarDeployableFile.java AbstractDeployableFile.java
ContainerWrapper.java Container.java
AbstractContainer.java
integration/ant/src/test/org/apache/cactus/integration/ant/container
MockContainer.java
integration/ant/src/java/org/apache/cactus/integration/ant/container/jboss
JBoss3xContainer.java
integration/ant/src/java/org/apache/cactus/integration/ant
CactusTask.java
documentation/docs/xdocs changes.xml
Log:
<action dev="VMA" type="fix" fixes-bug="25859" due-to="Brian Topping"
due-to-email="[EMAIL PROTECTED]">
In the Ant integration, added support for web contexts defined in
JBoss's <code>jboss-web.xml</code>.
</action>
Revision Changes Path
1.3 +15 -2
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/DeployableFile.java
Index: DeployableFile.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/DeployableFile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeployableFile.java 25 Oct 2003 18:42:27 -0000 1.2
+++ DeployableFile.java 10 Jan 2004 20:57:16 -0000 1.3
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -102,6 +102,12 @@
String getTestContext();
/**
+ * @param theTestContext the test context that will be used to test if the
+ * container is started or not
+ */
+ void setTestContext(String theTestContext);
+
+ /**
* Returns the first URL-pattern to which the Cactus servlet redirector is
* mapped in the deployment descriptor.
*
@@ -127,4 +133,11 @@
* not defined or mapped in the descriptor
*/
String getJspRedirectorMapping();
+
+ /**
+ * Clone the object.
+ * @return the object clone
+ * @throws CloneNotSupportedException If clone is not supported (duh)
+ */
+ Object clone() throws CloneNotSupportedException;
}
1.3 +4 -3
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/WarDeployableFile.java
Index: WarDeployableFile.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/WarDeployableFile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WarDeployableFile.java 25 Oct 2003 18:42:27 -0000 1.2
+++ WarDeployableFile.java 10 Jan 2004 20:57:16 -0000 1.3
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,8 @@
* @since Cactus 1.5
* @version $Id$
*/
-public class WarDeployableFile extends AbstractDeployableFile
+public class WarDeployableFile extends AbstractDeployableFile
+ implements Cloneable
{
/**
* @see DeployableFile#isWar()
1.5 +3 -2
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/EarDeployableFile.java
Index: EarDeployableFile.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/EarDeployableFile.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EarDeployableFile.java 25 Oct 2003 18:42:27 -0000 1.4
+++ EarDeployableFile.java 10 Jan 2004 20:57:16 -0000 1.5
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@
* @version $Id$
*/
public class EarDeployableFile extends AbstractDeployableFile
+ implements Cloneable
{
/**
* @see DeployableFile#isWar()
1.3 +22 -6
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractDeployableFile.java
Index: AbstractDeployableFile.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractDeployableFile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractDeployableFile.java 25 Oct 2003 18:42:27 -0000 1.2
+++ AbstractDeployableFile.java 10 Jan 2004 20:57:16 -0000 1.3
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,8 @@
* @since Cactus 1.5
* @version $Id$
*/
-public abstract class AbstractDeployableFile implements DeployableFile
+public abstract class AbstractDeployableFile
+ implements DeployableFile, Cloneable
{
/**
* The WAR or EAR file to deploy.
@@ -130,8 +131,7 @@
}
/**
- * @param theTestContext the test context that will be used to test if the
- * container is started or not
+ * @see DeployableFile#setTestContext(String)
*/
public final void setTestContext(String theTestContext)
{
@@ -193,7 +193,22 @@
{
return this.warArchive;
}
-
+
+ /**
+ * @see DeployableFile#clone()
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ AbstractDeployableFile file = (AbstractDeployableFile) super.clone();
+ file.deployableFile = this.deployableFile;
+ file.warArchive = this.warArchive;
+ file.testContext = this.testContext;
+ file.servletRedirectorMapping = this.servletRedirectorMapping;
+ file.filterRedirectorMapping = this.filterRedirectorMapping;
+ file.jspRedirectorMapping = this.jspRedirectorMapping;
+ return file;
+ }
+
/**
* @param theWarArchive the WAR archive object
*/
@@ -201,4 +216,5 @@
{
this.warArchive = theWarArchive;
}
+
}
1.9 +24 -16
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/ContainerWrapper.java
Index: ContainerWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/ContainerWrapper.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ContainerWrapper.java 23 Oct 2003 12:27:43 -0000 1.8
+++ ContainerWrapper.java 10 Jan 2004 20:57:16 -0000 1.9
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -99,13 +99,21 @@
// AbstractContainer Implementation ----------------------------------------
/**
- * @see Container#getName
+ * @see Container#getName()
*/
public String getName()
{
return container.getName();
}
-
+
+ /**
+ * @see Container#getTestContext()
+ */
+ public String getTestContext()
+ {
+ return this.container.getTestContext();
+ }
+
/**
* @see Container#getStartUpWait()
*/
@@ -115,7 +123,7 @@
}
/**
- * @see Container#getPort
+ * @see Container#getPort()
*/
public int getPort()
{
@@ -123,7 +131,7 @@
}
/**
- * @see Container#getToDir
+ * @see Container#getToDir()
*/
public File getToDir()
{
@@ -131,7 +139,7 @@
}
/**
- * @see Container#getSystemProperties
+ * @see Container#getSystemProperties()
*/
public Variable[] getSystemProperties()
{
@@ -139,7 +147,7 @@
}
/**
- * @see Container#init
+ * @see Container#init()
*/
public void init()
{
@@ -147,7 +155,7 @@
}
/**
- * @see Container#isEnabled
+ * @see Container#isEnabled()
*/
public boolean isEnabled()
{
@@ -155,7 +163,7 @@
}
/**
- * @see Container#isExcluded
+ * @see Container#isExcluded()
*/
public boolean isExcluded(String theTestName)
{
@@ -163,7 +171,7 @@
}
/**
- * @see Container#startUp
+ * @see Container#startUp()
*/
public void startUp()
{
@@ -171,7 +179,7 @@
}
/**
- * @see Container#shutDown
+ * @see Container#shutDown()
*/
public void shutDown()
{
@@ -179,7 +187,7 @@
}
/**
- * @see Container#setAntTaskFactory
+ * @see Container#setAntTaskFactory()
*/
public void setAntTaskFactory(AntTaskFactory theFactory)
{
@@ -187,7 +195,7 @@
}
/**
- * @see Container#setLog
+ * @see Container#setLog()
*/
public void setLog(Log theLog)
{
@@ -195,7 +203,7 @@
}
/**
- * @see Container#setDeployableFile
+ * @see Container#setDeployableFile()
*/
public void setDeployableFile(DeployableFile theWarFile)
{
@@ -203,7 +211,7 @@
}
/**
- * @see Container#setSystemProperties
+ * @see Container#setSystemProperties()
*/
public void setSystemProperties(Variable[] theProperties)
{
1.9 +8 -2
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/Container.java
Index: Container.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/Container.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Container.java 23 Nov 2003 16:50:34 -0000 1.8
+++ Container.java 10 Jan 2004 20:57:16 -0000 1.9
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -90,6 +90,12 @@
*/
int getPort();
+ /**
+ * @return the context that the webapp will load on, null if the client
+ * should determine on it's own
+ */
+ String getTestContext();
+
/**
* @return the time to wait after the container has been started up.
*/
1.12 +10 -2
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractContainer.java
Index: AbstractContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractContainer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractContainer.java 25 Oct 2003 18:42:27 -0000 1.11
+++ AbstractContainer.java 10 Jan 2004 20:57:16 -0000 1.12
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -144,6 +144,14 @@
// Public Methods ----------------------------------------------------------
+ /**
+ * @see Container#getTestContext()
+ */
+ public String getTestContext()
+ {
+ return null;
+ }
+
/**
* Sets the time to wait after the container has been started up.
*
1.10 +10 -2
jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/MockContainer.java
Index: MockContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/MockContainer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MockContainer.java 23 Oct 2003 12:27:42 -0000 1.9
+++ MockContainer.java 10 Jan 2004 20:57:16 -0000 1.10
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -131,6 +131,14 @@
return null;
}
+ /**
+ * @see Container#getTestContext()
+ */
+ public String getTestContext()
+ {
+ return null;
+ }
+
/**
* @see Container#getStartUpWait()
*/
1.11 +100 -9
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/jboss/JBoss3xContainer.java
Index: JBoss3xContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/jboss/JBoss3xContainer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JBoss3xContainer.java 7 Dec 2003 09:46:54 -0000 1.10
+++ JBoss3xContainer.java 10 Jan 2004 20:57:16 -0000 1.11
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,15 +58,27 @@
import java.io.File;
import java.io.IOException;
+import java.io.StringReader;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Special container support for the JBoss application server.
@@ -100,6 +112,11 @@
*/
private transient String version;
+ /**
+ * The context root of the tested application.
+ */
+ private String testContextRoot;
+
// Public Methods ----------------------------------------------------------
/**
@@ -146,7 +163,15 @@
// Container Implementation ------------------------------------------------
/**
- * @see org.apache.cactus.integration.ant.container.Container#getName
+ * @see AbstractContainer#getTestContext()
+ */
+ public String getTestContext()
+ {
+ return this.testContextRoot;
+ }
+
+ /**
+ * @see AbstractContainer#getName()
*/
public final String getName()
{
@@ -154,9 +179,7 @@
}
/**
- * Returns the port to which the container should listen.
- *
- * @return The port
+ * @see AbstractContainer#getPort()
*/
public final int getPort()
{
@@ -164,7 +187,7 @@
}
/**
- * @see org.apache.cactus.integration.ant.container.Container#init
+ * @see AbstractContainer#init()
*/
public final void init()
{
@@ -182,13 +205,17 @@
+ " of JBoss");
}
+ // Try to infer the test root context from the JBoss specific
+ // <code>jboss-web.xml</code> file.
+ this.testContextRoot = getTestContextFromJBossWebXml();
+
// TODO: as long as we don't have a way to set the port on the JBoss
// instance, we'll at least need to extract the port from a config file
// in the installation directory
}
/**
- * @see org.apache.cactus.integration.ant.container.Container#startUp
+ * @see AbstractContainer#startUp()
*/
public final void startUp()
{
@@ -229,7 +256,7 @@
}
/**
- * @see org.apache.cactus.integration.ant.container.Container#shutDown
+ * @see AbstractContainer#shutDown()
*/
public final void shutDown()
{
@@ -258,6 +285,29 @@
// Private Methods ---------------------------------------------------------
/**
+ * @return the test context from JBoss's <code>jboss-web.xml</code> or null
+ * if none has been defined or if the file doesn't exist
+ */
+ private String getTestContextFromJBossWebXml()
+ {
+ String testContext = null;
+
+ try
+ {
+ Document doc = getJBossWebXML();
+ Element root = doc.getDocumentElement();
+ Node context = root.getElementsByTagName("context-root").item(0);
+ testContext = context.getFirstChild().getNodeValue();
+ }
+ catch (Exception e)
+ {
+ // no worries if we can't find what we are looking for (for now).
+ }
+
+ return testContext;
+ }
+
+ /**
* Prepares a temporary installation of the container and deploys the
* web-application.
*
@@ -313,4 +363,45 @@
return retVal;
}
+ /**
+ * Get a Document object for the <code>jboss-web.xml</code> file.
+ *
+ * @return The parsed XML Document object or null if not found
+ * @throws IOException If there is a problem reading files
+ * @throws ParserConfigurationException If there is a problem w/ parser
+ * @throws SAXException If there is a problem with parsing
+ */
+ private Document getJBossWebXML() throws
+ IOException, ParserConfigurationException, SAXException
+ {
+ Document doc = null;
+ File configDir = new File(this.dir, "server");
+ File deployDir = new File(configDir, this.config + "/deploy");
+ File warFile = new File(deployDir,
+ getDeployableFile().getFile().getName());
+
+ JarFile war = new JarFile(warFile);
+ ZipEntry entry = war.getEntry("WEB-INF/jboss-web.xml");
+ if (entry != null)
+ {
+ DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(false);
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(new EntityResolver()
+ {
+ public InputSource resolveEntity(String thePublicId,
+ String theSystemId) throws SAXException
+ {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ doc = builder.parse(war.getInputStream(entry));
+ }
+ war.close();
+ return doc;
+ }
+
}
1.27 +28 -4
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTask.java
Index: CactusTask.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTask.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- CactusTask.java 9 Jan 2004 12:52:16 -0000 1.26
+++ CactusTask.java 10 Jan 2004 20:57:16 -0000 1.27
@@ -208,7 +208,31 @@
{
containers[i].setAntTaskFactory(this.antTaskFactory);
containers[i].setLog(new AntLog(this));
- containers[i].setDeployableFile(deployableFile);
+
+ // Clone the DeployableFile instance as each container can
+ // override default deployment properties (e.g. port, context
+ // root, etc).
+ DeployableFile thisDeployable = null;
+ try
+ {
+ thisDeployable = (DeployableFile) deployableFile.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new BuildException(e);
+ }
+ containers[i].setDeployableFile(thisDeployable);
+
+ // Allow the container to override the default test context.
+ // This is to support container extensions to the web.xml file.
+ // Most containers allow defining the root context in these
+ // extensions.
+ if (containers[i].getTestContext() != null)
+ {
+ thisDeployable.setTestContext(
+ containers[i].getTestContext());
+ }
+
containers[i].setSystemProperties(
(Variable[]) this.systemProperties.toArray(
new Variable[0]));
@@ -225,8 +249,8 @@
Project.MSG_INFO);
contextUrl.setValue(
"http://localhost:" + containers[i].getPort() + "/"
- + deployableFile.getTestContext());
- executeInContainer(containers[i], deployableFile);
+ + thisDeployable.getTestContext());
+ executeInContainer(containers[i], thisDeployable);
}
}
}
1.150 +4 -0 jakarta-cactus/documentation/docs/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- changes.xml 6 Jan 2004 14:46:32 -0000 1.149
+++ changes.xml 10 Jan 2004 20:57:16 -0000 1.150
@@ -68,6 +68,10 @@
</devs>
<release version="1.6dev" date="in CVS">
+ <action dev="VMA" type="fix" fixes-bug="25859" due-to="Brian Topping"
due-to-email="[EMAIL PROTECTED]">
+ In the Ant integration, added support for web contexts defined in
+ JBoss's <code>jboss-web.xml</code>.
+ </action>
<action dev="VMA" type="fix">
Fixed the bug where a ServletException occurs, stating:
<code>The request object passed to forward() must be the request
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]