You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/05/02 21:02:38 UTC
svn commit: r652873 - in /cxf/branches/2.0.x-fixes: ./
tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/
Author: dkulp
Date: Fri May 2 12:02:38 2008
New Revision: 652873
URL: http://svn.apache.org/viewvc?rev=652873&view=rev
Log:
Merged revisions 652869 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r652869 | dkulp | 2008-05-02 14:43:39 -0400 (Fri, 02 May 2008) | 2 lines
[CXF-1565] Fix a bunch of issues with JAXB binding files
........
Modified:
cxf/branches/2.0.x-fixes/ (props changed)
cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java
Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=652873&r1=652872&r2=652873&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Fri May 2 12:02:38 2008
@@ -50,6 +50,7 @@
import org.apache.cxf.helpers.MapNamespaceContext;
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.resource.URIResolver;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.tools.common.ToolConstants;
import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.common.ToolException;
@@ -184,15 +185,28 @@
private Node[] getAnnotationNodes(final Node node) {
Node[] nodes = new Node[2];
- Node annotationNode = nodeSelector.queryNode(node, "//xsd:annotation");
-
+ Node annotationNode = node.getFirstChild();
+ while (annotationNode != null) {
+ if ("annotation".equals(annotationNode.getLocalName())
+ && ToolConstants.SCHEMA_URI.equals(annotationNode.getNamespaceURI())) {
+ break;
+ }
+ annotationNode = annotationNode.getNextSibling();
+ }
if (annotationNode == null) {
annotationNode = node.getOwnerDocument().createElementNS(ToolConstants.SCHEMA_URI, "annotation");
}
nodes[0] = annotationNode;
- Node appinfoNode = nodeSelector.queryNode(annotationNode, "//xsd:appinfo");
+ Node appinfoNode = annotationNode.getFirstChild();
+ while (appinfoNode != null) {
+ if ("appinfo".equals(appinfoNode.getLocalName())
+ && ToolConstants.SCHEMA_URI.equals(appinfoNode.getNamespaceURI())) {
+ break;
+ }
+ appinfoNode = appinfoNode.getNextSibling();
+ }
if (appinfoNode == null) {
appinfoNode = node.getOwnerDocument().createElementNS(ToolConstants.SCHEMA_URI, "appinfo");
@@ -211,32 +225,32 @@
}
protected void copyAllJaxbDeclarations(final Node schemaNode, final Element jaxwsBindingNode) {
- Element jaxbBindingElement = getJaxbBindingElement(jaxwsBindingNode);
appendJaxbVersion((Element)schemaNode);
- if (jaxbBindingElement != null) {
- NodeList nlist = nodeSelector.queryNodes(schemaNode, jaxbBindingElement.getAttribute("node"));
- for (int i = 0; i < nlist.getLength(); i++) {
- Node node = nlist.item(i);
- copyAllJaxbDeclarations(node, jaxbBindingElement);
- }
- return;
- }
Node[] embededNodes = getAnnotationNodes(schemaNode);
Node annotationNode = embededNodes[0];
Node appinfoNode = embededNodes[1];
-
- NodeList childNodes = jaxwsBindingNode.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node childNode = childNodes.item(i);
- if (!isJaxbBindings(childNode) || isJaxbBindingsElement(childNode)) {
+
+ for (Node childNode = jaxwsBindingNode.getFirstChild();
+ childNode != null;
+ childNode = childNode.getNextSibling()) {
+ if (!isJaxbBindings(childNode)) {
continue;
}
-
- final Node jaxbNode = childNode;
-
- Node cloneNode = ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(), jaxbNode, true);
- appinfoNode.appendChild(cloneNode);
+
+ Element childEl = (Element)childNode;
+ if (isJaxbBindingsElement(childEl)) {
+ NodeList nlist = nodeSelector.queryNodes(schemaNode, childEl.getAttribute("node"));
+ for (int i = 0; i < nlist.getLength(); i++) {
+ Node node = nlist.item(i);
+ copyAllJaxbDeclarations(node, childEl);
+ }
+ } else {
+ final Node jaxbNode = childEl;
+ Node cloneNode = ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(), jaxbNode, true);
+ appinfoNode.appendChild(cloneNode);
+ childNode = childNode.getNextSibling();
+ }
}
if (schemaNode.getChildNodes().getLength() > 0) {
@@ -296,12 +310,9 @@
}
Element[] children = getChildElements(bindings, ToolConstants.NS_JAXWS_BINDINGS);
- for (int i = 0; i < children.length; i++) {
- if (children[i].getNodeType() == Node.ELEMENT_NODE) {
- internalizeBinding(children[i], targetNode, expression);
- }
+ for (Element child : children) {
+ internalizeBinding(child, targetNode, expression);
}
-
}
private void copyBindingsToWsdl(Node node, Node bindings, MapNamespaceContext ctx) {
@@ -378,9 +389,7 @@
private Element[] getChildElements(Element parent, String nsUri) {
List<Element> a = new ArrayList<Element>();
- NodeList children = parent.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node item = children.item(i);
+ for (Node item = parent.getFirstChild(); item != null; item = item.getNextSibling()) {
if (!(item instanceof Element)) {
continue;
}
@@ -392,10 +401,6 @@
}
private void addBinding(String bindingFile) throws XMLStreamException {
- InputSource is = new InputSource(bindingFile);
- XMLStreamReader reader = StAXUtil.createFreshXMLStreamReader(is);
-
- StAXUtil.toStartTag(reader);
Element root = null;
try {
@@ -405,6 +410,8 @@
Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
throw new ToolException(msg, e1);
}
+ XMLStreamReader reader = StaxUtils.createXMLStreamReader(root);
+ StAXUtil.toStartTag(reader);
if (isValidJaxwsBindingFile(bindingFile, reader)) {
String wsdlLocation = root.getAttribute("wsdlLocation");
@@ -454,7 +461,7 @@
}
jaxbBindings.add(tmpIns);
} else {
- jaxbBindings.add(is);
+ jaxbBindings.add(new InputSource(bindingFile));
}
} else {
@@ -562,18 +569,10 @@
return "bindings".equals(bindings.getLocalName());
}
- protected Element getJaxbBindingElement(final Element bindings) {
- NodeList list = bindings.getElementsByTagNameNS(ToolConstants.NS_JAXB_BINDINGS, "bindings");
- if (list.getLength() > 0) {
- return (Element)list.item(0);
- }
- return null;
- }
-
protected boolean hasJaxbBindingDeclaration(Node bindings) {
- NodeList childNodes = bindings.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node childNode = childNodes.item(i);
+ for (Node childNode = bindings.getFirstChild();
+ childNode != null;
+ childNode = childNode.getNextSibling()) {
if (isJaxbBindings(childNode)) {
return true;
}
Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java?rev=652873&r1=652872&r2=652873&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java (original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java Fri May 2 12:02:38 2008
@@ -62,8 +62,8 @@
}
void parseElement(JAXWSBinding jaxwsBinding, Element element) {
- NodeList children = element.getChildNodes();
- if (children != null && children.getLength() == 0) {
+ Node child = element.getFirstChild();
+ if (child == null) {
// global binding
if (isAsyncElement(element)) {
jaxwsBinding.setEnableAsyncMapping(getNodeValue(element));
@@ -78,33 +78,20 @@
if (isWrapperStyle(element)) {
jaxwsBinding.setEnableWrapperStyle(getNodeValue(element));
}
- }
-
- if (children != null && children.getLength() > 0) {
+ } else {
// other binding
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
-
+ while (child != null) {
if (isAsyncElement(child)) {
jaxwsBinding.setEnableAsyncMapping(getNodeValue(child));
- }
- if (isMIMEElement(child)) {
+ } else if (isMIMEElement(child)) {
jaxwsBinding.setEnableMime(getNodeValue(child));
- }
-
- if (isWrapperStyle(child)) {
+ } else if (isWrapperStyle(child)) {
jaxwsBinding.setEnableWrapperStyle(getNodeValue(child));
- }
-
- if (isPackageElement(child)) {
+ } else if (isPackageElement(child)) {
jaxwsBinding.setPackage(getPackageName(child));
- }
-
- if (isJAXWSMethodElement(child)) {
+ } else if (isJAXWSMethodElement(child)) {
jaxwsBinding.setMethodName(getMethodName(child));
- }
-
- if (isJAXWSParameterElement(child)) {
+ } else if (isJAXWSParameterElement(child)) {
Element childElement = (Element)child;
String partPath = "//" + childElement.getAttribute("part");
Node node = queryXPathNode(element.getOwnerDocument().getDocumentElement(), partPath);
@@ -121,9 +108,7 @@
String elementName = childElement.getAttribute("childElementName");
JAXWSParameter jpara = new JAXWSParameter(messageName, elementName, name);
jaxwsBinding.setJaxwsPara(jpara);
- }
-
- if (isJAXWSClass(child)) {
+ } else if (isJAXWSClass(child)) {
Element childElement = (Element)child;
String clzName = childElement.getAttribute("name");
String javadoc = "";
@@ -136,6 +121,7 @@
JAXWSClass jaxwsClass = new JAXWSClass(clzName, javadoc);
jaxwsBinding.setJaxwsClass(jaxwsClass);
}
+ child = child.getNextSibling();
}
}