Author: darran.lofthouse(a)jboss.com
Date: 2008-07-07 07:55:25 -0400 (Mon, 07 Jul 2008)
New Revision: 7789
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/JAXBWSDLGenerator.java
Log:
[JBWS-2250] Reference to JAXBElement Causes NullPointerException on deployment.
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/JAXBWSDLGenerator.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/JAXBWSDLGenerator.java 2008-07-07
11:55:00 UTC (rev 7788)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/JAXBWSDLGenerator.java 2008-07-07
11:55:25 UTC (rev 7789)
@@ -21,7 +21,14 @@
*/
package org.jboss.ws.tools.wsdl;
-import com.sun.xml.bind.api.JAXBRIContext;
+import java.io.IOException;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.extensions.security.Util;
@@ -29,12 +36,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.dom.DOMResult;
-import java.io.IOException;
+import com.sun.xml.bind.api.JAXBRIContext;
/**
* JAXBWSDLGenerator provides a JAXB based WSDLGenerator.
@@ -69,8 +71,7 @@
final Element element = types.getElement();
final Element throwAway = doc.createElement("throw-away");
- ctx.generateSchema(new SchemaOutputResolver()
- {
+ ctx.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespace, String file) throws IOException
{
@@ -79,8 +80,18 @@
wsdl.registerNamespaceURI(namespace, null);
// JAXB creates an empty namespace due to type references, ignore it
- DOMResult result = new DOMResult((namespace == null || namespace.length()
== 0) ? throwAway : element);
- result.setSystemId("replace-me");
+ DOMResult result = null;
+ if (namespace == null || namespace.length() == 0)
+ {
+ result = new DOMResult(throwAway);
+ result.setSystemId("remove-me");
+ }
+ else
+ {
+ result = new DOMResult(element);
+ result.setSystemId("replace-me");
+ }
+
return result;
}
});
@@ -100,10 +111,16 @@
{
for (Element child = Util.getFirstChildElement(element); child != null; child =
Util.getNextSiblingElement(child))
{
- if ("import".equals(child.getLocalName()) &&
Constants.NS_SCHEMA_XSD.equals(child.getNamespaceURI()) &&
"replace-me".equals(child.getAttribute("schemaLocation")))
+ if ("import".equals(child.getLocalName()) &&
Constants.NS_SCHEMA_XSD.equals(child.getNamespaceURI())
+ &&
"replace-me".equals(child.getAttribute("schemaLocation")))
{
child.removeAttribute("schemaLocation");
}
+ else if ("import".equals(child.getLocalName()) &&
Constants.NS_SCHEMA_XSD.equals(child.getNamespaceURI())
+ &&
"remove-me".equals(child.getAttribute("schemaLocation")))
+ {
+ element.removeChild(child);
+ }
else
{
removeSchemaLocations(child);
Show replies by date