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 20:43:40 UTC
svn commit: r652869 - in /cxf/trunk:
rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/
tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/
Author: dkulp
Date: Fri May 2 11:43:39 2008
New Revision: 652869
URL: http://svn.apache.org/viewvc?rev=652869&view=rev
Log:
[CXF-1565, CXF-1567] Fix problems with NPE in DynamicClientFactory as well as a bunch of issues with JAXB binding files
Modified:
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java
Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=652869&r1=652868&r2=652869&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java Fri May 2 11:43:39 2008
@@ -364,7 +364,10 @@
throws URISyntaxException, IOException {
JarFile jar = new JarFile(file);
- Attributes attr = jar.getManifest().getMainAttributes();
+ Attributes attr = null;
+ if (jar.getManifest() != null) {
+ attr = jar.getManifest().getMainAttributes();
+ }
if (attr != null) {
String cp = attr.getValue("Class-Path");
while (cp != null) {
Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=652869&r1=652868&r2=652869&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Fri May 2 11:43:39 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) {
@@ -283,12 +297,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) {
@@ -365,9 +376,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;
}
@@ -379,10 +388,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 {
@@ -392,6 +397,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");
@@ -441,7 +448,7 @@
}
jaxbBindings.add(tmpIns);
} else {
- jaxbBindings.add(is);
+ jaxbBindings.add(new InputSource(bindingFile));
}
} else {
@@ -549,18 +556,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/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java?rev=652869&r1=652868&r2=652869&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/JAXWSBindingParser.java Fri May 2 11:43:39 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();
}
}