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/11/13 23:23:16 UTC
svn commit: r836030 - in /cxf/branches/2.2.x-fixes: ./
common/common/src/main/java/org/apache/cxf/staxutils/
rt/core/src/main/java/org/apache/cxf/interceptor/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/
Author: dkulp
Date: Fri Nov 13 22:23:16 2009
New Revision: 836030
URL: http://svn.apache.org/viewvc?rev=836030&view=rev
Log:
Merged revisions 836024 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r836024 | dkulp | 2009-11-13 17:20:07 -0500 (Fri, 13 Nov 2009) | 2 lines
[CXF-2535] Fix problems with OverlayW3CDOMStreamWriter and optimize the
MMOI a bit
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeOutInterceptor.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java?rev=836030&r1=836029&r2=836030&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java Fri Nov 13 22:23:16 2009
@@ -19,6 +19,9 @@
package org.apache.cxf.staxutils;
+import java.util.LinkedList;
+import java.util.List;
+
import javax.xml.stream.XMLStreamException;
import org.w3c.dom.Document;
@@ -35,6 +38,9 @@
*/
public class OverlayW3CDOMStreamWriter extends W3CDOMStreamWriter {
+ List<Boolean> isOverlaidStack = new LinkedList<Boolean>();
+ boolean isOverlaid = true;
+
public OverlayW3CDOMStreamWriter(Document document) {
super(document);
}
@@ -43,50 +49,38 @@
super(e);
}
+ @Override
+ public void writeEndElement() throws XMLStreamException {
+ isOverlaid = isOverlaidStack.remove(0);
+ super.writeEndElement();
+ }
public void writeStartElement(String local) throws XMLStreamException {
- Element nd = getCurrentNode();
- Node nd2 = null;
- if (nd == null) {
- nd2 = getDocument().getDocumentElement();
- } else {
- nd2 = nd.getFirstChild();
- }
- while (nd2 != null) {
- if (nd2.getNodeType() == Node.ELEMENT_NODE
- && local.equals(nd2.getLocalName())
- && StringUtils.isEmpty(nd2.getNamespaceURI())) {
- setChild((Element)nd2, false);
- return;
+ isOverlaidStack.add(0, isOverlaid);
+ if (isOverlaid) {
+ Element nd = getCurrentNode();
+ Node nd2 = null;
+ if (nd == null) {
+ nd2 = getDocument().getDocumentElement();
+ } else {
+ nd2 = nd.getFirstChild();
+ }
+ while (nd2 != null) {
+ if (nd2.getNodeType() == Node.ELEMENT_NODE
+ && local.equals(nd2.getLocalName())
+ && StringUtils.isEmpty(nd2.getNamespaceURI())) {
+ setChild((Element)nd2, false);
+ return;
+ }
+ nd2 = nd2.getNextSibling();
}
- nd2 = nd2.getNextSibling();
}
+ isOverlaid = false;
super.writeStartElement(local);
}
public void writeStartElement(String namespace, String local) throws XMLStreamException {
- Element nd = getCurrentNode();
- Node nd2 = null;
- if (nd == null) {
- nd2 = getDocument().getDocumentElement();
- } else {
- nd2 = nd.getFirstChild();
- }
- while (nd2 != null) {
- if (nd2.getNodeType() == Node.ELEMENT_NODE
- && local.equals(nd2.getLocalName())
- && namespace.equals(nd2.getNamespaceURI())) {
- setChild((Element)nd2, false);
- return;
- }
- nd2 = nd2.getNextSibling();
- }
- super.writeStartElement(namespace, local);
- }
-
- public void writeStartElement(String prefix, String local, String namespace) throws XMLStreamException {
- if (prefix == null || prefix.equals("")) {
- writeStartElement(namespace, local);
- } else {
+ isOverlaidStack.add(0, isOverlaid);
+ if (isOverlaid) {
Element nd = getCurrentNode();
Node nd2 = null;
if (nd == null) {
@@ -94,7 +88,6 @@
} else {
nd2 = nd.getFirstChild();
}
-
while (nd2 != null) {
if (nd2.getNodeType() == Node.ELEMENT_NODE
&& local.equals(nd2.getLocalName())
@@ -104,9 +97,39 @@
}
nd2 = nd2.getNextSibling();
}
- super.writeStartElement(prefix, local, namespace);
}
+ isOverlaid = false;
+ super.writeStartElement(namespace, local);
}
+ public void writeStartElement(String prefix, String local, String namespace) throws XMLStreamException {
+ if (prefix == null || prefix.equals("")) {
+ writeStartElement(namespace, local);
+ } else {
+ isOverlaidStack.add(0, isOverlaid);
+ if (isOverlaid) {
+
+ Element nd = getCurrentNode();
+ Node nd2 = null;
+ if (nd == null) {
+ nd2 = getDocument().getDocumentElement();
+ } else {
+ nd2 = nd.getFirstChild();
+ }
+
+ while (nd2 != null) {
+ if (nd2.getNodeType() == Node.ELEMENT_NODE
+ && local.equals(nd2.getLocalName())
+ && namespace.equals(nd2.getNamespaceURI())) {
+ setChild((Element)nd2, false);
+ return;
+ }
+ nd2 = nd2.getNextSibling();
+ }
+ }
+ isOverlaid = false;
+ super.writeStartElement(prefix, local, namespace);
+ }
+ }
}
Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java?rev=836030&r1=836029&r2=836030&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java Fri Nov 13 22:23:16 2009
@@ -72,9 +72,15 @@
XMLStreamWriter xmlWriter = origXmlWriter;
CachingXmlEventWriter cache = null;
+ Object en = message.getContextualProperty(OUT_BUFFERING);
+ boolean allowBuffer = true;
+ boolean buffer = false;
+ if (en != null) {
+ buffer = Boolean.TRUE.equals(en) || "true".equals(en);
+ allowBuffer = !(Boolean.FALSE.equals(en) || "false".equals(en));
+ }
// need to cache the events in case validation fails or buffering is enabled
- if (shouldValidate(message) && !isRequestor(message)
- || isBufferingEnabled(message)) {
+ if (buffer || (allowBuffer && shouldValidate(message) && !isRequestor(message))) {
cache = new CachingXmlEventWriter();
try {
cache.setNamespaceContext(origXmlWriter.getNamespaceContext());
@@ -127,11 +133,6 @@
}
- protected boolean isBufferingEnabled(Message m) {
- Object en = m.getContextualProperty(OUT_BUFFERING);
- return Boolean.TRUE.equals(en) || "true".equals(en);
- }
-
protected boolean shouldValidate(Message m) {
Object en = m.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
return Boolean.TRUE.equals(en) || "true".equals(en);
Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeOutInterceptor.java?rev=836030&r1=836029&r2=836030&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeOutInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeOutInterceptor.java Fri Nov 13 22:23:16 2009
@@ -44,6 +44,7 @@
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor.SAAJOutEndingInterceptor;
import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.message.Message;
@@ -209,6 +210,13 @@
nd = soapMessage.getSOAPBody().getFirstChild();
}
list.set(0, frag);
+ //No need to buffer this as we're already a DOM,
+ //but only do so if someone hasn't actually configured this
+ Object buffer = message
+ .getContextualProperty(AbstractOutDatabindingInterceptor.OUT_BUFFERING);
+ if (buffer == null) {
+ message.put(AbstractOutDatabindingInterceptor.OUT_BUFFERING, Boolean.FALSE);
+ }
} catch (Exception ex) {
throw new Fault(ex);
}