ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1733797 - in /webservices/axiom/trunk: ./ aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/ aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/ aspects...
Date Sun, 06 Mar 2016 09:37:03 GMT
Author: veithen
Date: Sun Mar  6 09:37:03 2016
New Revision: 1733797

URL: http://svn.apache.org/viewvc?rev=1733797&view=rev
Log:
Rewrite the getXMLStreamReader implementation using the new stream API.

Added:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NamespaceURIInterningFilterHandler.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NamespaceURIInterningFilterHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/InternalXMLStreamReader.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/InternalXMLStreamReader.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXExceptionUtil.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXExceptionUtil.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/XMLStreamReaderExtensionFactory.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/XMLStreamReaderExtensionFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/AxiomXMLStreamReaderExtensionFactory.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/AxiomXMLStreamReaderExtensionFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/CharacterDataReaderImpl.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/CharacterDataReaderImpl.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/DTDReaderImpl.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/DTDReaderImpl.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/DataHandlerReaderImpl.java
      - copied unchanged from r1733796, webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/DataHandlerReaderImpl.java
Removed:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningNamespaceContextWrapper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningXMLStreamReaderWrapper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/
Modified:
    webservices/axiom/trunk/   (props changed)
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreNSAwareElementSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreParentNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
    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/DirectPushOMDataSourceReader.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
    webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java

Propchange: webservices/axiom/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar  6 09:37:03 2016
@@ -14,3 +14,4 @@
 /webservices/axiom/branches/maven-site-plugin-3.5:1731125-1732708
 /webservices/axiom/branches/namespaceURIInterning:1293148-1293587
 /webservices/axiom/branches/osgi-redesign:1180368-1180596
+/webservices/axiom/branches/stax-stream:1733528-1733796

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
Sun Mar  6 09:37:03 2016
@@ -18,26 +18,11 @@
  */
 package org.apache.axiom.core;
 
-import javax.xml.stream.XMLStreamReader;
-
 public interface Builder {
     int next();
     boolean isCompleted();
     void close();
     boolean isClosed();
 
-    /**
-     * Get the value of a feature/property from the underlying XMLStreamReader implementation
-     * without accessing the XMLStreamReader. https://issues.apache.org/jira/browse/AXIOM-348
-     *
-     * @param name
-     * @return TODO
-     */
-    Object getReaderProperty(String name) throws IllegalArgumentException;
-
-    XMLStreamReader disableCaching();
-
-    void reenableCaching(CoreParentNode container);
-
     void discard(CoreParentNode container);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
Sun Mar  6 09:37:03 2016
@@ -34,4 +34,6 @@ public interface InputContext {
      *             if a pass-through handler has already been set for this context
      */
     void setPassThroughHandler(XmlHandler passThroughHandler);
+
+    void discard();
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
Sun Mar  6 09:37:03 2016
@@ -25,6 +25,7 @@ import org.apache.axiom.core.CoreModelSt
 import org.apache.axiom.core.CoreNSAwareElement;
 import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.CoreParentNode;
+import org.apache.axiom.core.InputContext;
 import org.apache.axiom.core.NodeConsumedException;
 import org.apache.axiom.core.stream.DocumentElementExtractingFilterHandler;
 import org.apache.axiom.core.stream.StreamException;
@@ -79,6 +80,7 @@ public final class TreeWalkerImpl implem
     private final XmlHandler handler;
     private final CoreParentNode root;
     private final boolean preserve;
+    private final boolean incremental;
     private CoreNode node;
     
     /**
@@ -89,10 +91,11 @@ public final class TreeWalkerImpl implem
     
     private int state = STATE_NONE;
     
-    public TreeWalkerImpl(XmlHandler handler, CoreParentNode root, boolean preserve) {
+    public TreeWalkerImpl(XmlHandler handler, CoreParentNode root, boolean preserve, boolean
incremental) {
         this.handler = handler;
         this.root = root;
         this.preserve = preserve;
+        this.incremental = incremental;
     }
     
     @Override
@@ -206,7 +209,7 @@ public final class TreeWalkerImpl implem
             // been visited yet. It may be a sourced element or a leaf node
             if (state == STATE_NOT_VISITED) {
                 if (nextNode instanceof CoreNSAwareElement) {
-                    XmlInput input = ((CoreNSAwareElement)nextNode).getXmlInput(preserve);
+                    XmlInput input = ((CoreNSAwareElement)nextNode).getXmlInput(preserve,
incremental);
                     if (input != null) {
                         reader = input.createReader(new DocumentElementExtractingFilterHandler(handler));
                         state = STATE_STREAMING;
@@ -264,4 +267,24 @@ public final class TreeWalkerImpl implem
             throw new CoreModelStreamException(ex);
         }
     }
+
+    @Override
+    public void dispose() {
+        if (!preserve && node != null) {
+            CoreParentNode parent = node instanceof CoreParentNode ? (CoreParentNode)node
: ((CoreChildNode)node).coreGetParent();
+            while (true) {
+                InputContext context = parent.coreGetInputContext();
+                if (context != null) {
+                    context.discard();
+                }
+                if (parent == root) {
+                    break;
+                }
+                parent = ((CoreChildNode)parent).coreGetParent();
+            }
+        }
+        if (reader != null) {
+            reader.dispose();
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreNSAwareElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreNSAwareElementSupport.aj?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreNSAwareElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreNSAwareElementSupport.aj
Sun Mar  6 09:37:03 2016
@@ -38,7 +38,7 @@ public aspect CoreNSAwareElementSupport
         return namespaceURI.equals(coreGetNamespaceURI()) ? coreGetPrefix() : null;
     }
     
-    public XmlInput CoreNSAwareElement.getXmlInput(boolean cache) throws StreamException
{
+    public XmlInput CoreNSAwareElement.getXmlInput(boolean cache, boolean incremental) throws
StreamException {
         return null;
     }
     

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreParentNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreParentNodeSupport.aj?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreParentNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/mixin/CoreParentNodeSupport.aj
Sun Mar  6 09:37:03 2016
@@ -371,9 +371,13 @@ public aspect CoreParentNodeSupport {
         throw new UnsupportedOperationException();
     }
 
+    public final XmlReader CoreParentNode.coreGetReader(XmlHandler handler, boolean cache,
boolean incremental) {
+        return new TreeWalkerImpl(handler, this, cache, incremental);
+    }
+    
     public void CoreParentNode.internalSerialize(XmlHandler handler, boolean cache) throws
CoreModelException, StreamException {
         try {
-            XmlReader reader = new TreeWalkerImpl(handler, this, cache);
+            XmlReader reader = coreGetReader(handler, cache, false);
             while (!reader.proceed()) {
                 // Just loop
             }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
Sun Mar  6 09:37:03 2016
@@ -20,4 +20,5 @@ package org.apache.axiom.core.stream;
 
 public interface XmlReader {
     boolean proceed() throws StreamException;
+    void dispose();
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
Sun Mar  6 09:37:03 2016
@@ -65,4 +65,8 @@ public final class SAXReader implements
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
Sun Mar  6 09:37:03 2016
@@ -39,6 +39,7 @@ public final class BuilderHandler implem
     final Builder builder;
     final OMNamespaceCache nsCache = new OMNamespaceCache();
     public Context context;
+    private int activeContextCount;
     // returns the state of completion
     public boolean done;
     // keeps the state of the cache
@@ -61,6 +62,7 @@ public final class BuilderHandler implem
         this.root = root;
         this.builder = builder;
         context = new Context(this, null, 0);
+        activeContextCount = 1;
     }
 
     public void addListener(BuilderListener listener) {
@@ -93,6 +95,16 @@ public final class BuilderHandler implem
         }
     }
     
+    void incrementActiveContextCount() {
+        activeContextCount++;
+    }
+    
+    void decrementActiveContextCount() {
+        if (--activeContextCount == 0) {
+            builder.close();
+        }
+    }
+    
     public boolean isCompleted() {
         return done;
     }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
Sun Mar  6 09:37:03 2016
@@ -24,6 +24,7 @@ import org.apache.axiom.core.CoreCharact
 import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.core.InputContext;
+import org.apache.axiom.core.stream.NullXmlHandler;
 import org.apache.axiom.core.stream.StreamException;
 import org.apache.axiom.core.stream.XmlHandler;
 import org.apache.axiom.om.OMNamespace;
@@ -79,14 +80,25 @@ public final class Context implements In
         }
         target.coreSetState(CoreParentNode.DISCARDED);
         this.passThroughHandler = passThroughHandler;
+        if (passThroughHandler == NullXmlHandler.INSTANCE) {
+            builderHandler.decrementActiveContextCount();
+        }
     }
     
+    @Override
+    public void discard() {
+        target.coreSetState(CoreParentNode.DISCARDED);
+        passThroughHandler = NullXmlHandler.INSTANCE;
+        builderHandler.decrementActiveContextCount();
+    }
+
     private Context newContext(CoreParentNode target) {
         if (nestedContext == null) {
             nestedContext = new Context(builderHandler, this, depth+1);
         }
         nestedContext.target = target;
         target.coreSetInputContext(nestedContext);
+        builderHandler.incrementActiveContextCount();
         return nestedContext;
     }
     
@@ -98,11 +110,15 @@ public final class Context implements In
             pendingCharacterData = null;
         }
         target = null;
+        builderHandler.decrementActiveContextCount();
         return parentContext;
     }
     
     private Context decrementPassThroughDepth() {
         if (passThroughDepth == 0) {
+            if (passThroughHandler != NullXmlHandler.INSTANCE) {
+                builderHandler.decrementActiveContextCount();
+            }
             target.coreSetInputContext(null);
             target.coreSetState(CoreParentNode.DISCARDED);
             passThroughHandler = null;

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
Sun Mar  6 09:37:03 2016
@@ -18,8 +18,6 @@
  */
 package org.apache.axiom.om.impl.common.builder;
 
-import javax.xml.stream.XMLStreamReader;
-
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.core.stream.StreamException;
@@ -97,16 +95,6 @@ public final class PushBuilder extends A
     }
 
     @Override
-    public final XMLStreamReader disableCaching() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public final void reenableCaching(CoreParentNode container) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public final void discard(CoreParentNode container) {
         throw new UnsupportedOperationException();
     }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
Sun Mar  6 09:37:03 2016
@@ -392,4 +392,9 @@ public class StAXHelper implements XmlRe
         }
         return lookAheadToken;
     }
+
+    @Override
+    public void dispose() {
+        close();
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
Sun Mar  6 09:37:03 2016
@@ -30,8 +30,6 @@ import org.apache.axiom.om.impl.builder.
 import org.apache.axiom.om.impl.intf.AxiomContainer;
 import org.apache.axiom.om.impl.intf.AxiomElement;
 import org.apache.axiom.om.impl.intf.AxiomSourcedElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamReader;
@@ -39,8 +37,6 @@ import javax.xml.stream.XMLStreamReader;
 import java.io.Closeable;
 
 public class StAXOMBuilder extends AbstractBuilder implements CustomBuilderSupport {
-    private static final Log log = LogFactory.getLog(StAXOMBuilder.class);
-    
     private final StAXHelper helper;
 
     private final Detachable detachable;
@@ -173,58 +169,6 @@ public class StAXOMBuilder extends Abstr
         return helper.parser.getPrefix();
     }
 
-    public final XMLStreamReader disableCaching() {
-        builderHandler.cache = false;
-        // Always advance to the event right after the current node; this also takes
-        // care of lookahead
-        helper.parserNext();
-        if (log.isDebugEnabled()) {
-            log.debug("Caching disabled; current element level is " + builderHandler.depth);
-        }
-        return helper.parser;
-    }
-    
-    // This method expects that the parser is currently positioned on the
-    // end event corresponding to the container passed as parameter
-    public final void reenableCaching(CoreParentNode container) {
-        Context current = builderHandler.context;
-        while (true) {
-            discarded(current.target);
-            if (builderHandler.depth == 0) {
-                if (current.target != container || current.target != builderHandler.document)
{
-                    throw new IllegalStateException();
-                }
-                break;
-            }
-            builderHandler.depth--;
-            if (current.target == container) {
-                break;
-            }
-            current = current.parentContext;
-        }
-        // Note that at this point current == container
-        if (container == builderHandler.document) {
-            builderHandler.context = null;
-            builderHandler.done = true;
-        } else if (builderHandler.depth == 0 && builderHandler.document == null)
{
-            // Consume the remaining event; for the rationale, see StAXOMBuilder#next()
-            while (helper.parserNext() != XMLStreamConstants.END_DOCUMENT) {
-                // Just loop
-            }
-            builderHandler.context = null;
-            builderHandler.done = true;
-        } else {
-            builderHandler.context = builderHandler.context.parentContext;
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("Caching re-enabled; new element level: " + builderHandler.depth +
"; done=" + builderHandler.done);
-        }
-        if (builderHandler.done && helper.autoClose) {
-            close();
-        }
-        builderHandler.cache = true;
-    }
-
     @Override
     public void registerCustomBuilder(Selector selector, CustomBuilder customBuilder) {
         if (customBuilderManager == null) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
Sun Mar  6 09:37:03 2016
@@ -38,13 +38,16 @@ import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.ElementMatcher;
 import org.apache.axiom.core.Mapper;
 import org.apache.axiom.core.stream.NamespaceRepairingFilterHandler;
+import org.apache.axiom.core.stream.NamespaceURIInterningFilterHandler;
 import org.apache.axiom.core.stream.StreamException;
 import org.apache.axiom.core.stream.XmlHandler;
 import org.apache.axiom.core.stream.sax.XmlHandlerContentHandler;
+import org.apache.axiom.core.stream.stax.StAXPivot;
 import org.apache.axiom.core.stream.stax.XMLStreamWriterNamespaceContextProvider;
 import org.apache.axiom.om.NodeUnavailableException;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSerializable;
@@ -54,10 +57,9 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
-import org.apache.axiom.om.impl.common.NamespaceURIInterningXMLStreamReaderWrapper;
 import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
 import org.apache.axiom.om.impl.common.SAXResultContentHandler;
-import org.apache.axiom.om.impl.common.serializer.pull.PullSerializer;
+import org.apache.axiom.om.impl.common.serializer.push.NamespaceContextPreservationFilterHandler;
 import org.apache.axiom.om.impl.common.serializer.push.XmlDeclarationRewriterHandler;
 import org.apache.axiom.om.impl.common.serializer.push.XsiTypeFilterHandler;
 import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
@@ -65,8 +67,8 @@ import org.apache.axiom.om.impl.common.s
 import org.apache.axiom.om.impl.intf.AxiomChildNode;
 import org.apache.axiom.om.impl.intf.AxiomContainer;
 import org.apache.axiom.om.impl.intf.OMFactoryEx;
+import org.apache.axiom.om.impl.stream.stax.AxiomXMLStreamReaderExtensionFactory;
 import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axiom.util.stax.debug.XMLStreamReaderValidator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.xml.sax.InputSource;
@@ -101,27 +103,28 @@ public aspect AxiomContainerSupport {
     }
     
     public final XMLStreamReader AxiomContainer.defaultGetXMLStreamReader(boolean cache,
OMXMLStreamReaderConfiguration configuration) {
-        Builder builder = coreGetBuilder();
-        if (builder != null && builder.isCompleted() && !cache &&
!isComplete()) {
-            throw new UnsupportedOperationException("The parser is already consumed!");
-        }
-        XMLStreamReader reader = new PullSerializer(this, cache, configuration.isPreserveNamespaceContext());
-        
+        StAXPivot pivot = new StAXPivot(AxiomXMLStreamReaderExtensionFactory.INSTANCE);
+        XmlHandler handler = pivot;
         if (configuration.isNamespaceURIInterning()) {
-            reader = new NamespaceURIInterningXMLStreamReaderWrapper(reader);
+            handler = new NamespaceURIInterningFilterHandler(handler);
+        }
+        CoreElement contextElement = getContextElement();
+        if (contextElement != null) {
+            if (configuration.isPreserveNamespaceContext()) {
+                handler = new NamespaceContextPreservationFilterHandler(handler, contextElement);
+            } else {
+                for (Iterator<OMNamespace> it = ((OMElement)contextElement).getNamespacesInScope();
it.hasNext(); ) {
+                    OMNamespace ns = it.next();
+                    pivot.setPrefix(ns.getPrefix(), ns.getNamespaceURI());
+                }
+            }
         }
-        
-        // If debug is enabled, wrap the OMXMLStreamReader in a validator.
-        // The validator will check for mismatched events to help determine if the OMStAXWrapper
-        // is functioning correctly.  All problems are reported as debug.log messages
-        
-        if (log.isDebugEnabled()) {
-            reader = 
-                new XMLStreamReaderValidator(reader, // delegate to actual reader
-                     false); // log problems (true will cause exceptions to be thrown)
+        try {
+            pivot.setReader(coreGetReader(handler, cache, true));
+        } catch (StreamException ex) {
+            throw new OMException(ex);
         }
-        
-        return reader;
+        return pivot;
     }
     
     public final AxiomChildNode AxiomContainer.prepareNewChild(OMNode omNode) {

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=1733797&r1=1733796&r2=1733797&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
Sun Mar  6 09:37:03 2016
@@ -403,13 +403,25 @@ public aspect AxiomSourcedElementSupport
         }
     }
 
-    public final XmlInput AxiomSourcedElement.getXmlInput(boolean cache) throws StreamException
{
-        if (isExpanded() || (cache && OMDataSourceUtil.isDestructiveWrite(dataSource)))
{
+    public final XmlInput AxiomSourcedElement.getXmlInput(boolean cache, boolean incremental)
throws StreamException {
+        if (isExpanded()) {
             return null;
         }
-        // Note: if we can't determine the type (push/pull) of the OMDataSource, we
-        // default to push
+        boolean pull;
         if (OMDataSourceUtil.isPullDataSource(dataSource)) {
+            pull = true;
+        } else if (OMDataSourceUtil.isPushDataSource(dataSource)) {
+            if (incremental) {
+                return null;
+            }
+            pull = false;
+        } else {
+            pull = incremental;
+        }
+        if (cache && (pull && OMDataSourceUtil.isDestructiveRead(dataSource)
|| !pull && OMDataSourceUtil.isDestructiveWrite(dataSource))) {
+            return null;
+        }
+        if (pull) {
             try {
                 return new StAXPullInput(dataSource.getReader());
             } catch (XMLStreamException ex) {

Modified: 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=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
Sun Mar  6 09:37:03 2016
@@ -43,4 +43,8 @@ final class DirectPushOMDataSourceReader
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
Sun Mar  6 09:37:03 2016
@@ -62,4 +62,8 @@ final class PushOMDataSourceReader imple
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
Sun Mar  6 09:37:03 2016
@@ -25,7 +25,6 @@ import org.apache.axiom.om.impl.dom.fact
 import org.apache.axiom.ts.om.OMTestSuiteBuilder;
 import org.apache.axiom.ts.om.document.TestDigest;
 import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
-import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithPreserveNamespaceContext;
 import org.apache.axiom.ts.om.element.sr.TestClose;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
 import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
@@ -51,9 +50,6 @@ public class OMImplementationTest extend
         // TODO: test case needing review
         builder.exclude(TestClose.class);
         
-        // TODO: the namespace context is different when cache=false
-        builder.exclude(TestGetXMLStreamReaderWithPreserveNamespaceContext.class, "(cache=false)");
-        
         return builder.build();
     }
 }

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1733797&r1=1733796&r2=1733797&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Sun Mar  6 09:37:03 2016
@@ -24,7 +24,6 @@ import junit.framework.TestSuite;
 import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
 import org.apache.axiom.ts.om.OMTestSuiteBuilder;
 import org.apache.axiom.ts.om.document.TestDigest;
-import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithPreserveNamespaceContext;
 import org.apache.axiom.ts.om.element.sr.TestClose;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
 import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
@@ -46,9 +45,6 @@ public class OMImplementationTest extend
         // TODO: test case needing review
         builder.exclude(TestClose.class);
         
-        // TODO: the namespace context is different when cache=false
-        builder.exclude(TestGetXMLStreamReaderWithPreserveNamespaceContext.class, "(cache=false)");
-        
         return builder.build();
     }
 }




Mime
View raw message