Author: richard.opalka(a)jboss.com
Date: 2007-09-25 07:07:56 -0400 (Tue, 25 Sep 2007)
New Revision: 4624
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/AbstractDeployerHookJSE.java
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXRPCDeployerHookPreJSE.java
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXWSDeployerHookPreJSE.java
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/ModifyWebMetaDataDeploymentAspect.java
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebAppDeploymentAspect.java
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebXMLRewriterImpl.java
Log:
[JBWS-1762] fix of the issue for jboss40 integration layer - merge to trunk
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/AbstractDeployerHookJSE.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/AbstractDeployerHookJSE.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/AbstractDeployerHookJSE.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -21,6 +21,16 @@
*/
package org.jboss.wsf.container.jboss40;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
import org.jboss.deployment.DeploymentInfo;
import org.jboss.metadata.WebMetaData;
@@ -60,4 +70,38 @@
return servletName;
}
}
+
+ // JBWS 1762
+ Map<String, String> getServletClassMap(URL resource)
+ {
+ if (resource == null)
+ return null;
+
+ File origWebXml = new File(resource.getFile());
+ if (origWebXml.isDirectory())
+ return null;
+
+ Map<String, String> retVal = new HashMap<String, String>();
+ try
+ {
+ FileInputStream source = new FileInputStream(origWebXml);
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(source);
+ Element root = document.getRootElement();
+ for (Iterator it = root.elementIterator("servlet"); it.hasNext();)
+ {
+ Element servlet = (Element)it.next();
+ String servletName =
servlet.element("servlet-name").getTextTrim();
+ Element servletClass = servlet.element("servlet-class");
+ retVal.put(servletName, servletClass == null ? null :
servletClass.getTextTrim());
+ }
+ }
+ catch (Exception ignore)
+ {
+ return null;
+ }
+
+ return retVal.size() > 0 ? retVal : null;
+ }
+
}
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXRPCDeployerHookPreJSE.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXRPCDeployerHookPreJSE.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXRPCDeployerHookPreJSE.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -87,7 +87,7 @@
if (servletLink == null)
throw new IllegalStateException("servlet-link cannot be null");
- Servlet servlet = getServletForName(webMetaData, servletLink);
+ Servlet servlet = getServletForName(webMetaData, di.annotationsCl,
servletLink, dep);
String servletClass = servlet.getServletClass();
try
@@ -114,9 +114,22 @@
return dep;
}
- private Servlet getServletForName(WebMetaData wmd, String servletLink)
+ private Servlet getServletForName(WebMetaData wmd, ClassLoader loader, String
servletLink, Deployment dep)
{
- Iterator it = wmd.getServletClassMap().entrySet().iterator();
+ // JBWS 1762
+ Map servletClassMap =
getServletClassMap(loader.getResource("WEB-INF/web.xml.org"));
+
+ if (servletClassMap != null)
+ {
+ if (dep != null)
+ dep.setProperty("org.jboss.ws.webapp.modify", "false");
+ }
+ else
+ {
+ servletClassMap = wmd.getServletClassMap();
+ }
+
+ Iterator it = servletClassMap.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Entry)it.next();
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXWSDeployerHookPreJSE.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXWSDeployerHookPreJSE.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/JAXWSDeployerHookPreJSE.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -73,7 +73,7 @@
// Copy the attachments
dep.addAttachment(WebMetaData.class, webMetaData);
- List<Servlet> servlets = getRelevantServlets(webMetaData, di.annotationsCl);
+ List<Servlet> servlets = getRelevantServlets(webMetaData, di.annotationsCl,
dep);
for (Servlet servlet : servlets)
{
String servletName = servlet.getServletName();
@@ -98,7 +98,7 @@
try
{
WebMetaData webMetaData = (WebMetaData)unit.metaData;
- List<Servlet> servlets = getRelevantServlets(webMetaData,
unit.annotationsCl);
+ List<Servlet> servlets = getRelevantServlets(webMetaData,
unit.annotationsCl, null);
isWebServiceDeployment = servlets.size() > 0;
}
catch (Exception ex)
@@ -109,10 +109,23 @@
return isWebServiceDeployment;
}
- private List<Servlet> getRelevantServlets(WebMetaData webMetaData, ClassLoader
loader)
+ private List<Servlet> getRelevantServlets(WebMetaData webMetaData, ClassLoader
loader, Deployment dep)
{
+ // JBWS 1762
+ Map servletClassMap =
getServletClassMap(loader.getResource("WEB-INF/web.xml.org"));
+
+ if (servletClassMap != null)
+ {
+ if (dep != null)
+ dep.setProperty("org.jboss.ws.webapp.modify", "false");
+ }
+ else
+ {
+ servletClassMap = webMetaData.getServletClassMap();
+ }
+
List<Servlet> servlets = new ArrayList<Servlet>();
- Iterator it = webMetaData.getServletClassMap().entrySet().iterator();
+ Iterator it = servletClassMap.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Entry)it.next();
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/ModifyWebMetaDataDeploymentAspect.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/ModifyWebMetaDataDeploymentAspect.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/ModifyWebMetaDataDeploymentAspect.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -23,12 +23,6 @@
//$Id: ModifyWebMetaDataDeployer.java 3772 2007-07-01 19:29:13Z thomas.diesler(a)jboss.com
$
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URL;
-
-import javax.xml.ws.WebServiceException;
-
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -68,35 +62,4 @@
}
}
- public void destroy(Deployment dep)
- {
- URL warURL = (URL)dep.getProperty("org.jboss.ws.webapp.url");
- File warFile = new File(warURL.getFile());
- if (warFile.isDirectory() == false)
- throw new WebServiceException("Expected a war directory: " + warURL);
-
- File webXML = new File(warURL.getFile() + "/WEB-INF/web.xml");
- if (webXML.isFile() == false)
- throw new WebServiceException("Cannot find web.xml: " + webXML);
-
- try
- {
- // On destroy remove the modified web.xml and rollback
web.xml.org to web.xml
- File orgWebXML = new File(webXML.getCanonicalPath() + ".org");
- webXML.delete();
-
- // Rename the
web.xml.org
- if (orgWebXML.renameTo(webXML) == false)
- throw new WebServiceException("Cannot rename web.xml: " +
orgWebXML);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception e)
- {
- throw new WebServiceException(e);
- }
- }
-
}
\ No newline at end of file
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebAppDeploymentAspect.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebAppDeploymentAspect.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebAppDeploymentAspect.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -64,6 +64,8 @@
log.debug("publishServiceEndpoint: " + warURL);
try
{
+ // JBWS 1762
+ dep.setProperty("org.jboss.ws.webapp.descriptor.suffix",
".ejb.org");
webXMLRewriter.rewriteWebXml(dep);
DeploymentInfo auxdi = new DeploymentInfo(warURL, null,
MBeanServerLocator.locateJBoss());
Modified:
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebXMLRewriterImpl.java
===================================================================
---
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebXMLRewriterImpl.java 2007-09-25
11:05:47 UTC (rev 4623)
+++
container/jboss40/trunk/src/main/java/org/jboss/wsf/container/jboss40/WebXMLRewriterImpl.java 2007-09-25
11:07:56 UTC (rev 4624)
@@ -75,15 +75,24 @@
try
{
- // After redeployment there might be a stale copy of the original
web.xml.org,
we delete it
- File orgWebXML = new File(webXML.getCanonicalPath() + ".org");
- orgWebXML.delete();
+ FileInputStream stream = new FileInputStream(webXML);
+ String modifyProperty =
(String)dep.getProperty("org.jboss.ws.webapp.modify");
+
+ // JBWS 1762
+ if ((modifyProperty == null) || (!modifyProperty.equals("false")))
+ {
+ String suffix =
(String)dep.getProperty("org.jboss.ws.webapp.descriptor.suffix");
+ if (suffix == null)
+ suffix = ".org";
+ File orgWebXML = new File(webXML.getCanonicalPath() + suffix);
- // Rename the web.xml
- if (webXML.renameTo(orgWebXML) == false)
- throw new WebServiceException("Cannot rename web.xml: " +
orgWebXML);
+ // Rename the web.xml
+ if (webXML.renameTo(orgWebXML) == false)
+ throw new WebServiceException("Cannot rename web.xml: " +
orgWebXML);
+
+ stream = new FileInputStream(orgWebXML);
+ }
- FileInputStream stream = new FileInputStream(orgWebXML);
return rewriteWebXml(stream, webXML, dep);
}
catch (RuntimeException rte)
@@ -110,11 +119,15 @@
RewriteResults results = desciptorModifier.modifyDescriptor(dep, document);
results.webXML = destFile.toURL();
- FileOutputStream fos = new FileOutputStream(destFile);
- OutputFormat format = OutputFormat.createPrettyPrint();
- XMLWriter writer = new XMLWriter(fos, format);
- writer.write(document);
- writer.close();
+ String modifyProperty =
(String)dep.getProperty("org.jboss.ws.webapp.modify");
+ if ((modifyProperty == null) || (!modifyProperty.equals("false")))
+ {
+ FileOutputStream fos = new FileOutputStream(destFile);
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ XMLWriter writer = new XMLWriter(fos, format);
+ writer.write(document);
+ writer.close();
+ }
return results;
}