You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/27 10:49:41 UTC

svn commit: r1732616 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl: mixin/AxiomSourcedElementSupport.aj stream/ds/DirectPushOMDataSourceReader.java stream/ds/PushOMDataSourceInput.java

Author: veithen
Date: Sat Feb 27 09:49:41 2016
New Revision: 1732616

URL: http://svn.apache.org/viewvc?rev=1732616&view=rev
Log:
Move the XmlHandler unwrapping logic from AxiomSourcedElementSupport to PushOMDataSourceInput.

Added:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java   (with props)
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceInput.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementSupport.aj?rev=1732616&r1=1732615&r2=1732616&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementSupport.aj Sat Feb 27 09:49:41 2016
@@ -24,7 +24,6 @@ import org.apache.axiom.core.CoreElement
 import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.stream.StreamException;
 import org.apache.axiom.core.stream.XmlHandler;
-import org.apache.axiom.core.stream.XmlHandlerWrapper;
 import org.apache.axiom.om.DeferredParsingException;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMDataSource;
@@ -40,7 +39,6 @@ import org.apache.axiom.om.impl.common.b
 import org.apache.axiom.om.impl.common.builder.PushBuilder;
 import org.apache.axiom.om.impl.common.builder.StAXHelper;
 import org.apache.axiom.om.impl.common.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer;
 import org.apache.axiom.om.impl.common.util.OMDataSourceUtil;
 import org.apache.axiom.om.impl.intf.AxiomSourcedElement;
 import org.apache.axiom.om.impl.stream.ds.PushOMDataSourceInput;
@@ -437,19 +435,7 @@ public aspect AxiomSourcedElementSupport
                 throw new DeferredParsingException(ex);
             }
         } else {
-            XmlHandler unwrappedHandler = handler;
-            while (unwrappedHandler instanceof XmlHandlerWrapper) {
-                unwrappedHandler = ((XmlHandlerWrapper)unwrappedHandler).getParent();
-            }
-            if (unwrappedHandler instanceof StAXSerializer) {
-                try {
-                    dataSource.serialize(((StAXSerializer)unwrappedHandler).getWriter());
-                } catch (XMLStreamException ex) {
-                    throw new StreamException(ex);
-                }
-            } else {
-                new PushOMDataSourceInput(this, dataSource).createReader(handler).proceed();
-            }
+            new PushOMDataSourceInput(this, dataSource).createReader(handler).proceed();
         }
     }
 

Added: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java?rev=1732616&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java (added)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java Sat Feb 27 09:49:41 2016
@@ -0,0 +1,45 @@
+/*
+ * 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.stream.ds;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.core.stream.StreamException;
+import org.apache.axiom.core.stream.XmlReader;
+import org.apache.axiom.om.OMDataSource;
+
+final class DirectPushOMDataSourceReader implements XmlReader {
+    private final XMLStreamWriter writer;
+    private final OMDataSource dataSource;
+
+    DirectPushOMDataSourceReader(XMLStreamWriter writer, OMDataSource dataSource) {
+        this.writer = writer;
+        this.dataSource = dataSource;
+    }
+
+    @Override
+    public void proceed() throws StreamException {
+        try {
+            dataSource.serialize(writer);
+        } catch (XMLStreamException ex) {
+            throw new StreamException(ex);
+        }
+    }
+}

Propchange: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceInput.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceInput.java?rev=1732616&r1=1732615&r2=1732616&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceInput.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceInput.java Sat Feb 27 09:49:41 2016
@@ -19,9 +19,11 @@
 package org.apache.axiom.om.impl.stream.ds;
 
 import org.apache.axiom.core.stream.XmlHandler;
+import org.apache.axiom.core.stream.XmlHandlerWrapper;
 import org.apache.axiom.core.stream.XmlInput;
 import org.apache.axiom.core.stream.XmlReader;
 import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer;
 import org.apache.axiom.om.impl.intf.AxiomSourcedElement;
 
 public final class PushOMDataSourceInput implements XmlInput {
@@ -35,6 +37,14 @@ public final class PushOMDataSourceInput
     
     @Override
     public XmlReader createReader(XmlHandler handler) {
-        return new PushOMDataSourceReader(handler, root, dataSource);
+        XmlHandler unwrappedHandler = handler;
+        while (unwrappedHandler instanceof XmlHandlerWrapper) {
+            unwrappedHandler = ((XmlHandlerWrapper)unwrappedHandler).getParent();
+        }
+        if (unwrappedHandler instanceof StAXSerializer) {
+            return new DirectPushOMDataSourceReader(((StAXSerializer)unwrappedHandler).getWriter(), dataSource);
+        } else {
+            return new PushOMDataSourceReader(handler, root, dataSource);
+        }
     }
 }