ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1733683 - in /webservices/axiom/branches/stax-stream/aspects: core-aspects/src/main/java/org/apache/axiom/core/ core-aspects/src/main/java/org/apache/axiom/core/impl/ core-aspects/src/main/java/org/apache/axiom/core/stream/ core-aspects/sr...
Date Sat, 05 Mar 2016 00:23:48 GMT
Author: veithen
Date: Sat Mar  5 00:23:48 2016
New Revision: 1733683

URL: http://svn.apache.org/viewvc?rev=1733683&view=rev
Log:
Implement discard-on-close.

Added:
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
  (with props)
Modified:
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
    webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
    webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
    webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
    webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
    webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java

Modified: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/InputContext.java
Sat Mar  5 00:23:48 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/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
Sat Mar  5 00:23:48 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;
@@ -264,4 +265,21 @@ 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();
+            }
+        }
+    }
 }

Added: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java?rev=1733683&view=auto
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
(added)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
Sat Mar  5 00:23:48 2016
@@ -0,0 +1,98 @@
+/*
+ * 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.core.stream;
+
+public final class NullXmlHandler implements XmlHandler {
+    public static final NullXmlHandler INSTANCE = new NullXmlHandler();
+
+    private NullXmlHandler() {}
+
+    @Override
+    public void startDocument(String inputEncoding, String xmlVersion, String xmlEncoding,
+            boolean standalone) throws StreamException {
+    }
+
+    @Override
+    public void startFragment() throws StreamException {
+    }
+
+    @Override
+    public void processDocumentTypeDeclaration(String rootName, String publicId, String systemId,
+            String internalSubset) throws StreamException {
+    }
+
+    @Override
+    public void startElement(String namespaceURI, String localName, String prefix)
+            throws StreamException {
+    }
+
+    @Override
+    public void endElement() throws StreamException {
+    }
+
+    @Override
+    public void processAttribute(String namespaceURI, String localName, String prefix, String
value,
+            String type, boolean specified) throws StreamException {
+    }
+
+    @Override
+    public void processNamespaceDeclaration(String prefix, String namespaceURI)
+            throws StreamException {
+    }
+
+    @Override
+    public void attributesCompleted() throws StreamException {
+    }
+
+    @Override
+    public void processCharacterData(Object data, boolean ignorable) throws StreamException
{
+    }
+
+    @Override
+    public void startProcessingInstruction(String target) throws StreamException {
+    }
+
+    @Override
+    public void endProcessingInstruction() throws StreamException {
+    }
+
+    @Override
+    public void startComment() throws StreamException {
+    }
+
+    @Override
+    public void endComment() throws StreamException {
+    }
+
+    @Override
+    public void startCDATASection() throws StreamException {
+    }
+
+    @Override
+    public void endCDATASection() throws StreamException {
+    }
+
+    @Override
+    public void processEntityReference(String name, String replacementText) throws StreamException
{
+    }
+
+    @Override
+    public void completed() throws StreamException {
+    }
+}

Propchange: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlReader.java
Sat Mar  5 00:23:48 2016
@@ -20,4 +20,5 @@ package org.apache.axiom.core.stream;
 
 public interface XmlReader {
     boolean proceed() throws StreamException;
+    void dispose();
 }

Modified: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/SAXReader.java
Sat Mar  5 00:23:48 2016
@@ -65,4 +65,8 @@ public final class SAXReader implements
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }

Modified: webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/StAXPivot.java
Sat Mar  5 00:23:48 2016
@@ -498,8 +498,8 @@ public final class StAXPivot implements
 
     @Override
     public void close() throws XMLStreamException {
-        // TODO Auto-generated method stub
-        
+        // TODO: update state
+        reader.dispose();
     }
 
     int getNamespaceBindingsCount() {

Modified: webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/Context.java
Sat Mar  5 00:23:48 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;
@@ -81,6 +82,12 @@ public final class Context implements In
         this.passThroughHandler = passThroughHandler;
     }
     
+    @Override
+    public void discard() {
+        target.coreSetState(CoreParentNode.DISCARDED);
+        passThroughHandler = NullXmlHandler.INSTANCE;
+    }
+
     private Context newContext(CoreParentNode target) {
         if (nestedContext == null) {
             nestedContext = new Context(builderHandler, this, depth+1);

Modified: webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
Sat Mar  5 00:23:48 2016
@@ -392,4 +392,10 @@ public class StAXHelper implements XmlRe
         }
         return lookAheadToken;
     }
+
+    @Override
+    public void dispose() {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
 }

Modified: webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/DirectPushOMDataSourceReader.java
Sat Mar  5 00:23:48 2016
@@ -43,4 +43,8 @@ final class DirectPushOMDataSourceReader
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }

Modified: webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java?rev=1733683&r1=1733682&r2=1733683&view=diff
==============================================================================
--- webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
(original)
+++ webservices/axiom/branches/stax-stream/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/ds/PushOMDataSourceReader.java
Sat Mar  5 00:23:48 2016
@@ -62,4 +62,8 @@ final class PushOMDataSourceReader imple
         }
         return true;
     }
+
+    @Override
+    public void dispose() {
+    }
 }



Mime
View raw message