Author: dkulp
Date: Tue Feb 5 11:50:05 2008
New Revision: 618759
URL: http://svn.apache.org/viewvc?rev=618759&view=rev
Log:
Use DOM when convert back/forth between reference types to make it just a tree
walk and not full parse.
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=618759&r1=618758&r2=618759&view=diff
==============================================================================
---
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Tue Feb 5 11:50:05 2008
@@ -40,6 +40,7 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
@@ -73,6 +74,7 @@
import org.apache.cxf.resource.ExtendedURIResolver;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.MultiplexDestination;
import org.apache.cxf.ws.addressing.AttributedURIType;
@@ -857,9 +859,6 @@
}
public static Source convertToXML(EndpointReferenceType epr) {
- StreamResult result = new StreamResult();
- java.io.StringWriter s = new java.io.StringWriter();
- result.setWriter(s);
try {
JAXBContext jaxbContext =
JAXBContext.newInstance(new Class[]
{WSA_WSDL_OBJECT_FACTORY.getClass(),
@@ -869,12 +868,17 @@
QName qname = new QName("http://www.w3.org/2005/08/addressing",
"EndpointReference");
JAXBElement<EndpointReferenceType>
jaxEle = new JAXBElement<EndpointReferenceType>(qname,
EndpointReferenceType.class, epr);
- jm.marshal(jaxEle, result);
+
+
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
+ jm.marshal(jaxEle, writer);
+ return new DOMSource(writer.getDocument());
} catch (JAXBException e) {
- return null;
+ //ignore
+ } catch (ParserConfigurationException e) {
+ //ignore
}
- java.io.StringReader strReader = new
java.io.StringReader(s.toString());
- return new StreamSource(strReader);
+ return null;
}
Modified:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=618759&r1=618758&r2=618759&view=diff
==============================================================================
---
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Tue Feb 5 11:50:05 2008
@@ -33,6 +33,7 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
+import org.w3c.dom.TypeInfo;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.AbstractDOMStreamReader.ElementFrame;
@@ -245,15 +246,15 @@
}
public String getAttributeType(int i) {
- return toStaxType(getAttribute(i).getNodeType());
- }
-
- public static String toStaxType(short jdom) {
- switch (jdom) {
- default:
- return null;
+ Attr attr = getAttribute(i);
+ if (attr.isId()) {
+ return "ID";
}
+ TypeInfo schemaType = attr.getSchemaTypeInfo();
+ return (schemaType == null) ? "CDATA"
+ : schemaType.getTypeName() == null ? "CDATA" :
schemaType.getTypeName();
}
+
public String getAttributeValue(int i) {
return getAttribute(i).getValue();
Modified:
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java?rev=618759&r1=618758&r2=618759&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
(original)
+++
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
Tue Feb 5 11:50:05 2008
@@ -20,23 +20,24 @@
package org.apache.cxf.ws.addressing;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import org.w3c.dom.Document;
+
// importation convention: if the same class name is used for
// 2005/08 and 2004/08, then the former version is imported
// and the latter is fully qualified when used
-import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamReader;
import org.apache.cxf.ws.addressing.v200408.AttributedQName;
import org.apache.cxf.ws.addressing.v200408.AttributedURI;
import org.apache.cxf.ws.addressing.v200408.ObjectFactory;
@@ -201,26 +202,27 @@
*/
public static EndpointReferenceType convertToInternal(EndpointReference
external) {
if (external instanceof W3CEndpointReference) {
- CachedOutputStream cos = new CachedOutputStream();
- Result r = new StreamResult(cos);
- external.writeTo(r);
-
- JAXBContext jaxbContext;
+
+
try {
+ Document doc = XMLUtils.newDocument();
+ DOMResult result = new DOMResult(doc);
+ external.writeTo(result);
+ W3CDOMStreamReader reader = new
W3CDOMStreamReader(doc.getDocumentElement());
+
// CXF internal 2005/08 EndpointReferenceType should be
// compatible with W3CEndpointReference
//jaxContext = ContextUtils.getJAXBContext();
- jaxbContext = JAXBContext
- .newInstance(new Class[]
{org.apache.cxf.ws.addressing.ObjectFactory.class,
-
org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class});
+ JAXBContext jaxbContext = JAXBContext
+ .newInstance(new Class[]
{org.apache.cxf.ws.addressing.ObjectFactory.class});
EndpointReferenceType internal =
jaxbContext.createUnmarshaller()
- .unmarshal(new StreamSource(cos.getInputStream()),
EndpointReferenceType.class)
+ .unmarshal(reader, EndpointReferenceType.class)
.getValue();
return internal;
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (IOException e) {
+ } catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}