Author: thomas.diesler(a)jboss.com
Date: 2006-11-23 02:29:30 -0500 (Thu, 23 Nov 2006)
New Revision: 1516
Removed:
trunk/src/main/java/org/jboss/ws/transport/
Modified:
trunk/src/main/java/org/jboss/ws/WSException.java
trunk/src/main/java/org/jboss/ws/deployment/AbstractServiceEndpointPublisher.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java
Log:
[JBWS-1093] Deploying a war that also contains normal servlets the web.xml is modified as
if they are all endpoints
Modified: trunk/src/main/java/org/jboss/ws/WSException.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/WSException.java 2006-11-23 07:08:49 UTC (rev 1515)
+++ trunk/src/main/java/org/jboss/ws/WSException.java 2006-11-23 07:29:30 UTC (rev 1516)
@@ -51,4 +51,12 @@
{
super(cause);
}
+
+ public static void rethrow(String string, Throwable th)
+ {
+ if (th instanceof WSException)
+ throw (WSException)th;
+
+ throw new WSException(string, th);
+ }
}
Modified:
trunk/src/main/java/org/jboss/ws/deployment/AbstractServiceEndpointPublisher.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/deployment/AbstractServiceEndpointPublisher.java 2006-11-23
07:08:49 UTC (rev 1515)
+++
trunk/src/main/java/org/jboss/ws/deployment/AbstractServiceEndpointPublisher.java 2006-11-23
07:29:30 UTC (rev 1516)
@@ -23,9 +23,7 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -34,13 +32,14 @@
import java.util.List;
import java.util.Map;
+import javax.servlet.Servlet;
+
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
-import org.jboss.ws.server.ServerConfig;
-import org.jboss.ws.server.ServerConfigFactory;
import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.utils.DOMWriter;
import org.jboss.ws.utils.IOUtils;
+import org.jboss.ws.utils.JavaUtils;
import org.w3c.dom.Element;
/**
@@ -98,7 +97,7 @@
throw new WSException("Cannot rename web.xml: " + orgWebXML);
FileInputStream stream = new FileInputStream(orgWebXML);
- return rewriteWebXml(stream, webXML).toURL();
+ return rewriteWebXml(stream, webXML, null).toURL();
}
catch (RuntimeException rte)
{
@@ -110,7 +109,7 @@
}
}
- public File rewriteWebXml(InputStream source, File dest) throws IOException,
FileNotFoundException
+ public File rewriteWebXml(InputStream source, File dest, ClassLoader loader) throws
Exception
{
if (dest == null)
{
@@ -119,7 +118,7 @@
}
Element root = DOMUtils.parse(source);
- modifyServletConfig(root);
+ modifyServletConfig(root, loader);
FileOutputStream fos = new FileOutputStream(dest);
new DOMWriter(fos).setPrettyprint(true).print(root);
@@ -129,7 +128,7 @@
return dest;
}
- private Map<String, String> modifyServletConfig(Element root)
+ private Map<String, String> modifyServletConfig(Element root, ClassLoader
loader) throws ClassNotFoundException
{
Map<String, String> sepTargetMap = new HashMap<String, String>();
@@ -148,6 +147,7 @@
// Get the servlet class
String servletClassName = DOMUtils.getTextContent(classElement);
+ Class servletClass = (loader != null ? loader.loadClass(servletClassName) :
null);
String targetBeanName = null;
@@ -155,8 +155,13 @@
if (isAlreadyModified(servletElement) == false)
{
// Check if it is a real servlet that we can ignore
- if (servletClassName.endsWith("Servlet"))
+ if (servletClass != null && JavaUtils.isAssignableFrom(Servlet.class,
servletClass))
{
+ log.info("Ignore servlet: " + servletClassName);
+ continue;
+ }
+ else if (servletClassName.endsWith("Servlet"))
+ {
log.info("Ignore <servlet-class> that ends with
'Servlet': " + servletClassName);
continue;
}
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java 2006-11-23
07:08:49 UTC (rev 1515)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java 2006-11-23
07:29:30 UTC (rev 1516)
@@ -21,10 +21,10 @@
*/
package org.jboss.ws.integration.jboss50;
+//$Id$
+
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
@@ -48,9 +48,6 @@
import org.jboss.ws.server.ServerConfigFactory;
import org.jboss.ws.utils.IOUtils;
-//$Id$
-
-
/**
* An abstract deployer for JSE Endpoints
*
@@ -89,11 +86,17 @@
try
{
InputStream stream =
unit.getDeploymentContext().getRoot().findChild("WEB-INF/web.xml").openStream();
- return getServiceEndpointPublisher().rewriteWebXml(stream, null).toString();
+ ClassLoader loader = unit.getClassLoader();
+ return getServiceEndpointPublisher().rewriteWebXml(stream, null,
loader).toString();
}
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
catch (Exception e)
{
- throw new WSException("Could not generate alternate deployment
descriptor", e);
+ WSException.rethrow("Could not generate alternate deployment
descriptor", e);
+ return null;
}
}