ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1447028 - in /webservices/axiom/trunk/modules: axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/ axiom-impl/src/test/j...
Date Sun, 17 Feb 2013 14:07:27 GMT
Author: veithen
Date: Sun Feb 17 14:07:27 2013
New Revision: 1447028

URL: http://svn.apache.org/r1447028
Log:
Initial implementation of OMDataSource to SAX serialization (in push mode).

Added:
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
  (with props)
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java
  (with props)
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java
  (with props)
Modified:
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
    webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java

Added: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java?rev=1447028&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
(added)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
Sun Feb 17 14:07:27 2013
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common.serializer.push.sax;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.util.namespace.ScopedNamespaceContext;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+final class ContentHandlerXMLStreamWriter implements XMLStreamWriter {
+    private final SAXHelper helper;
+    private final ContentHandler contentHandler;
+    private final LexicalHandler lexicalHandler;
+    
+    /**
+     * The namespace context of the {@link XMLStreamWriter}. This namespace context is inherited
+     * from the {@link SAXSerializer}.
+     */
+    private final ScopedNamespaceContext writerNsContext;
+
+    /**
+     * Tracks the namespace declarations actually written using
+     * {@link XMLStreamWriter#writeNamespace(String, String)} and
+     * {@link XMLStreamWriter#writeDefaultNamespace(String)}. Note that the
+     * {@link ScopedNamespaceContext} is actually not used as a {@link NamespaceContext},
but merely
+     * to remember the namespace declarations. This is necessary to generate the necessary
+     * {@link ContentHandler#endPrefixMapping(String)} events.
+     */
+    private final ScopedNamespaceContext outputNsContext = new ScopedNamespaceContext();
+    
+    private final AttributesImpl attributes = new AttributesImpl();
+
+    ContentHandlerXMLStreamWriter(SAXHelper helper, ContentHandler contentHandler, LexicalHandler
lexicalHandler,
+            ScopedNamespaceContext nsContext) {
+        this.helper = helper;
+        this.contentHandler = contentHandler;
+        this.lexicalHandler = lexicalHandler;
+        writerNsContext = nsContext;
+    }
+
+    private static String normalize(String s) {
+        return s == null ? "" : s;
+    }
+    
+    public NamespaceContext getNamespaceContext() {
+        return writerNsContext;
+    }
+
+    public void setDefaultNamespace(String uri) throws XMLStreamException {
+        writerNsContext.setPrefix("", normalize(uri));
+    }
+
+    public String getPrefix(String uri) throws XMLStreamException {
+        return writerNsContext.getPrefix(uri);
+    }
+
+    public void writeStartElement(String prefix, String localName, String namespaceURI) throws
XMLStreamException {
+        finishStartElementIfNecessary();
+        helper.beginStartElement(normalize(prefix), normalize(namespaceURI), localName);
+        writerNsContext.startScope();
+        outputNsContext.startScope();
+    }
+
+    public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
+        namespaceURI = normalize(namespaceURI);
+        outputNsContext.setPrefix("", namespaceURI);
+        try {
+            contentHandler.startPrefixMapping("", namespaceURI);
+        } catch (SAXException ex) {
+            throw new SAXExceptionWrapper(ex);
+        }
+    }
+
+    public void writeAttribute(String prefix, String namespaceURI, String localName, String
value) throws XMLStreamException {
+        helper.addAttribute(normalize(prefix), normalize(namespaceURI), localName, "CDATA",
value);
+    }
+
+    private void finishStartElementIfNecessary() throws XMLStreamException {
+        if (helper.isInStartElement()) {
+            try {
+                helper.finishStartElement(contentHandler);
+            } catch (SAXException ex) {
+                throw new SAXExceptionWrapper(ex);
+            }
+        }
+    }
+    
+    public void writeEndElement() throws XMLStreamException {
+        finishStartElementIfNecessary();
+        try {
+            helper.writeEndElement(contentHandler, outputNsContext);
+            writerNsContext.endScope();
+        } catch (SAXException ex) {
+            throw new SAXExceptionWrapper(ex);
+        }
+    }
+
+    public void writeCharacters(String text) throws XMLStreamException {
+        finishStartElementIfNecessary();
+        try {
+            char[] ch = text.toCharArray();
+            contentHandler.characters(ch, 0, ch.length);
+        } catch (SAXException ex) {
+            throw new SAXExceptionWrapper(ex);
+        }
+    }
+
+    public void flush() throws XMLStreamException {
+    }
+
+    public void close() throws XMLStreamException {
+    }
+
+    public Object getProperty(String name) throws IllegalArgumentException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void setPrefix(String prefix, String uri) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeAttribute(String localName, String value) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeAttribute(String namespaceURI, String localName, String value)
+            throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeCData(String data) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeCharacters(char[] text, int start, int len) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeComment(String data) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeDTD(String dtd) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeEmptyElement(String localName) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeEmptyElement(String prefix, String localName, String namespaceURI)
+            throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeEndDocument() throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeEntityRef(String name) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeProcessingInstruction(String target) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeProcessingInstruction(String target, String data) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeStartDocument() throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeStartDocument(String version) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeStartDocument(String encoding, String version) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeStartElement(String localName) throws XMLStreamException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java?rev=1447028&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java
(added)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java
Sun Feb 17 14:07:27 2013
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common.serializer.push.sax;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.xml.sax.SAXException;
+
+final class SAXExceptionWrapper extends XMLStreamException {
+    private static final long serialVersionUID = -8523524667092495463L;
+
+    SAXExceptionWrapper(SAXException cause) {
+        super(cause);
+    }
+}

Propchange: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXExceptionWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java?rev=1447028&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java
(added)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java
Sun Feb 17 14:07:27 2013
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common.serializer.push.sax;
+
+import java.util.Stack;
+
+import org.apache.axiom.util.namespace.ScopedNamespaceContext;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+final class SAXHelper {
+    private Stack elementNameStack = new Stack();
+    private String elementURI;
+    private String elementLocalName;
+    private String elementQName;
+    private final AttributesImpl attributes = new AttributesImpl();
+
+    private static String getQName(String prefix, String localName) {
+        if (prefix.length() == 0) {
+            return localName;
+        } else {
+            return prefix + ":" + localName;
+        }
+    }
+    
+    void beginStartElement(String prefix, String namespaceURI, String localName) {
+        elementURI = namespaceURI;
+        elementLocalName = localName;
+        elementQName = getQName(prefix, localName);
+    }
+
+    void addAttribute(String prefix, String namespaceURI, String localName, String type,
String value) {
+        attributes.addAttribute(namespaceURI, localName, getQName(prefix, localName), type,
value);
+    }
+
+    void finishStartElement(ContentHandler contentHandler) throws SAXException {
+        contentHandler.startElement(elementURI, elementLocalName, elementQName, attributes);
+        elementNameStack.push(elementURI);
+        elementNameStack.push(elementLocalName);
+        elementNameStack.push(elementQName);
+        elementURI = null;
+        elementLocalName = null;
+        elementQName = null;
+        attributes.clear();
+    }
+
+    boolean isInStartElement() {
+        return elementLocalName != null;
+    }
+    
+    void writeEndElement(ContentHandler contentHandler, ScopedNamespaceContext nsContext)
throws SAXException {
+        String elementQName = (String)elementNameStack.pop();
+        String elementLocalName = (String)elementNameStack.pop();
+        String elementURI = (String)elementNameStack.pop();
+        contentHandler.endElement(elementURI, elementLocalName, elementQName);
+        for (int i=nsContext.getBindingsCount()-1; i>=nsContext.getFirstBindingInCurrentScope();
i--) {
+            contentHandler.endPrefixMapping(nsContext.getPrefix(i));
+        }
+        nsContext.endScope();
+    }
+}

Propchange: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java?rev=1447028&r1=1447027&r2=1447028&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
Sun Feb 17 14:07:27 2013
@@ -19,9 +19,10 @@
 package org.apache.axiom.om.impl.common.serializer.push.sax;
 
 import java.io.IOException;
-import java.util.Stack;
 
 import javax.activation.DataHandler;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
 import org.apache.axiom.om.OMDataSource;
@@ -34,7 +35,6 @@ import org.apache.axiom.util.namespace.S
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
 
 public class SAXSerializer extends Serializer {
     private final ContentHandler contentHandler;
@@ -43,11 +43,7 @@ public class SAXSerializer extends Seria
     private boolean startDocumentWritten;
     private boolean autoStartDocument;
     private int depth;
-    private Stack elementNameStack = new Stack();
-    private String elementURI;
-    private String elementLocalName;
-    private String elementQName;
-    private final AttributesImpl attributes = new AttributesImpl();
+    private final SAXHelper helper = new SAXHelper();
     
     public SAXSerializer(OMSerializable contextNode, ContentHandler contentHandler, LexicalHandler
lexicalHandler) {
         super(contextNode);
@@ -59,14 +55,6 @@ public class SAXSerializer extends Seria
         return nsContext.getNamespaceURI(prefix).equals(namespace);
     }
 
-    private static String getQName(String prefix, String localName) {
-        if (prefix.length() == 0) {
-            return localName;
-        } else {
-            return prefix + ":" + localName;
-        }
-    }
-    
     private void writeStartDocument() throws OutputException {
         try {
             contentHandler.startDocument();
@@ -100,9 +88,7 @@ public class SAXSerializer extends Seria
             writeStartDocument();
             autoStartDocument = true;
         }
-        elementURI = namespaceURI;
-        elementLocalName = localName;
-        elementQName = getQName(prefix, localName);
+        helper.beginStartElement(prefix, namespaceURI, localName);
         nsContext.startScope();
         depth++;
     }
@@ -118,34 +104,20 @@ public class SAXSerializer extends Seria
     }
 
     protected void addAttribute(String prefix, String namespaceURI, String localName, String
type, String value) throws OutputException {
-        attributes.addAttribute(namespaceURI, localName, getQName(prefix, localName), type,
value);
+        helper.addAttribute(prefix, namespaceURI, localName, type, value);
     }
 
     protected void finishStartElement() throws OutputException {
         try {
-            contentHandler.startElement(elementURI, elementLocalName, elementQName, attributes);
+            helper.finishStartElement(contentHandler);
         } catch (SAXException ex) {
             throw new SAXOutputException(ex);
         }
-        elementNameStack.push(elementURI);
-        elementNameStack.push(elementLocalName);
-        elementNameStack.push(elementQName);
-        elementURI = null;
-        elementLocalName = null;
-        elementQName = null;
-        attributes.clear();
     }
 
     public void writeEndElement() throws OutputException {
         try {
-            String elementQName = (String)elementNameStack.pop();
-            String elementLocalName = (String)elementNameStack.pop();
-            String elementURI = (String)elementNameStack.pop();
-            contentHandler.endElement(elementURI, elementLocalName, elementQName);
-            for (int i=nsContext.getBindingsCount()-1; i>=nsContext.getFirstBindingInCurrentScope();
i--) {
-                contentHandler.endPrefixMapping(nsContext.getPrefix(i));
-            }
-            nsContext.endScope();
+            helper.writeEndElement(contentHandler, nsContext);
             if (--depth == 0 && autoStartDocument) {
                 contentHandler.endDocument();
             }
@@ -214,7 +186,7 @@ public class SAXSerializer extends Seria
             Throwable cause = ex.getCause();
             SAXException saxException;
             if (cause instanceof SAXException) {
-                saxException = (SAXException)ex.getCause();
+                saxException = (SAXException)cause;
             } else {
                 saxException = new SAXException(ex);
             }
@@ -229,8 +201,22 @@ public class SAXSerializer extends Seria
     }
 
     protected void serializePushOMDataSource(OMDataSource dataSource) throws OutputException
{
-        // TODO
-        throw new UnsupportedOperationException();
+        try {
+            XMLStreamWriter writer = new ContentHandlerXMLStreamWriter(helper, contentHandler,
lexicalHandler, nsContext);
+            if (startDocumentWritten) {
+                dataSource.serialize(writer);
+            } else {
+                contentHandler.startDocument();
+                dataSource.serialize(writer);
+                contentHandler.endDocument();
+            }
+        } catch (SAXException ex) {
+            throw new SAXOutputException(ex);
+        } catch (SAXExceptionWrapper ex) {
+            throw new SAXOutputException((SAXException)ex.getCause());
+        } catch (XMLStreamException ex) {
+            throw new SAXOutputException(new SAXException(ex));
+        }
     }
 
     public void writeEndDocument() throws OutputException {

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java?rev=1447028&r1=1447027&r2=1447028&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
Sun Feb 17 14:07:27 2013
@@ -41,12 +41,11 @@ public class StAXSerializer extends Seri
     private static final Log log = LogFactory.getLog(StAXSerializer.class);
     
     private final XMLStreamWriter writer;
-    private final DataHandlerWriter dataHandlerWriter;
+    private DataHandlerWriter dataHandlerWriter;
     
     public StAXSerializer(OMSerializable contextNode, XMLStreamWriter writer) {
         super(contextNode);
         this.writer = writer;
-        dataHandlerWriter = XMLStreamWriterUtils.getDataHandlerWriter(writer);
     }
 
     protected void serializePushOMDataSource(OMDataSource dataSource) throws OutputException
{
@@ -243,9 +242,17 @@ public class StAXSerializer extends Seri
         }
     }
 
+    private DataHandlerWriter getDataHandlerWriter() {
+        // We only retrieve/create the DataHandlerWriter if necessary
+        if (dataHandlerWriter == null) {
+            dataHandlerWriter = XMLStreamWriterUtils.getDataHandlerWriter(writer);
+        }
+        return dataHandlerWriter;
+    }
+
     public void writeDataHandler(DataHandler dataHandler, String contentID, boolean optimize)
throws OutputException {
         try {
-            dataHandlerWriter.writeDataHandler(dataHandler, contentID, optimize);
+            getDataHandlerWriter().writeDataHandler(dataHandler, contentID, optimize);
         } catch (IOException ex) {
             throw new StAXOutputException(new XMLStreamException("Error while reading data
handler", ex));
         } catch (XMLStreamException ex) {
@@ -255,7 +262,7 @@ public class StAXSerializer extends Seri
 
     public void writeDataHandler(DataHandlerProvider dataHandlerProvider, String contentID,
boolean optimize) throws OutputException {
         try {
-            dataHandlerWriter.writeDataHandler(dataHandlerProvider, contentID, optimize);
+            getDataHandlerWriter().writeDataHandler(dataHandlerProvider, contentID, optimize);
         } catch (IOException ex) {
             throw new StAXOutputException(new XMLStreamException("Error while reading data
handler", ex));
         } catch (XMLStreamException ex) {

Modified: webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1447028&r1=1447027&r2=1447028&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Sun Feb 17 14:07:27 2013
@@ -50,12 +50,6 @@ public class OMImplementationTest extend
         
         // TODO: if there is a comment node surrounded by text, then these text nodes need
to be merged
         builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
-
-        // TODO: getSAXSource doesn't honor the cache flag yet
-        builder.exclude(org.apache.axiom.ts.om.sourcedelement.TestSerialize.class, "(&(serializationStrategy=SAXSource)(cache=false))");
-        
-        // TODO: the SAXSource returned by getSAXSource always expands OMSourcedElements
-        builder.exclude(org.apache.axiom.ts.om.sourcedelement.TestSerialize.class, "(&(serializationStrategy=SAXSource)(destructive=false))");
         
         return builder.build();
     }



Mime
View raw message