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 2009/05/14 00:11:41 UTC
svn commit: r774558 - in /cxf/trunk:
common/common/src/main/java/org/apache/cxf/staxutils/
rt/core/src/main/java/org/apache/cxf/databinding/source/
systests/src/test/java/org/apache/cxf/systest/ws/security/
Author: dkulp
Date: Wed May 13 22:11:40 2009
New Revision: 774558
URL: http://svn.apache.org/viewvc?rev=774558&view=rev
Log:
Some optimizations for message mode SOAP dispatcher things
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java
cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java?rev=774558&r1=774557&r2=774558&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java Wed May 13 22:11:40 2009
@@ -203,6 +203,17 @@
*/
public abstract String getElementText() throws XMLStreamException;
+ public void consumeFrame() {
+ frame.started = true;
+ frame.ended = true;
+ if (frame.isDocument()) {
+ currentEvent = END_DOCUMENT;
+ } else {
+ currentEvent = END_ELEMENT;
+ endElement();
+ }
+ }
+
/*
* (non-Javadoc)
*
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=774558&r1=774557&r2=774558&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Wed May 13 22:11:40 2009
@@ -44,7 +44,9 @@
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamReader;
@@ -116,8 +118,19 @@
// Use a DOMSource for now, we should really use a StaxSource/SAXSource though for
// performance reasons
try {
- Document document = StaxUtils.read(reader);
- return new DOMSource(document);
+ XMLStreamReader reader2 = reader;
+ if (reader2 instanceof DepthXMLStreamReader) {
+ reader2 = ((DepthXMLStreamReader)reader2).getReader();
+ }
+ if (reader2 instanceof W3CDOMStreamReader) {
+ W3CDOMStreamReader domreader = (W3CDOMStreamReader)reader2;
+ Object o = new DOMSource(domreader.getCurrentElement());
+ domreader.consumeFrame();
+ return o;
+ } else {
+ Document document = StaxUtils.read(reader);
+ return new DOMSource(document);
+ }
} catch (XMLStreamException e) {
throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
}
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java?rev=774558&r1=774557&r2=774558&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java Wed May 13 22:11:40 2009
@@ -63,7 +63,7 @@
&& ((W3CDOMStreamWriter)writer).getCurrentNode() != null) {
W3CDOMStreamWriter dw = (W3CDOMStreamWriter)writer;
- if (nd.getOwnerDocument() == dw.getDocument()) {
+ if (nd.getOwnerDocument() == dw.getCurrentNode().getOwnerDocument()) {
dw.getCurrentNode().appendChild(nd);
return;
} else if (nd instanceof DocumentFragment) {
Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java?rev=774558&r1=774557&r2=774558&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java Wed May 13 22:11:40 2009
@@ -42,8 +42,9 @@
import javax.xml.xpath.XPathConstants;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
@@ -224,13 +225,15 @@
source = disp.invoke(source);
DOMSource ds = (DOMSource)source;
- Element el = ((Document)ds.getNode()).getDocumentElement();
+ Node nd = ds.getNode();
+ if (nd instanceof Document) {
+ nd = ((Document)nd).getDocumentElement();
+ }
Map<String, String> ns = new HashMap<String, String>();
ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
XPathUtils xp = new XPathUtils(ns);
- Object o = xp.getValue("/ns2:DoubleItResponse/doubledNumber", el, XPathConstants.STRING);
- assertEquals("50", o);
-
+ Object o = xp.getValue("//ns2:DoubleItResponse/doubledNumber", nd, XPathConstants.STRING);
+ assertEquals(XMLUtils.toString(nd), "50", o);
}
@@ -302,11 +305,15 @@
public Source invoke(Source obj) {
//CHECK the incoming
DOMSource ds = (DOMSource)obj;
- Element el = ((Document)ds.getNode()).getDocumentElement();
+
+ Node el = ds.getNode();
+ if (el instanceof Document) {
+ el = ((Document)el).getDocumentElement();
+ }
Map<String, String> ns = new HashMap<String, String>();
ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
XPathUtils xp = new XPathUtils(ns);
- String o = (String)xp.getValue("/ns2:DoubleIt/numberToDouble", el, XPathConstants.STRING);
+ String o = (String)xp.getValue("//ns2:DoubleIt/numberToDouble", el, XPathConstants.STRING);
int i = Integer.parseInt(o);
String req = "<ns2:DoubleItResponse xmlns:ns2=\"http://cxf.apache.org/policytest/DoubleIt\">"