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 2012/02/25 13:22:38 UTC

svn commit: r1293589 - in /webservices/commons/trunk/modules/axiom: ./ modules/axiom-api/src/main/java/org/apache/axiom/om/ modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ modules/axiom-testsuite/src/main/java/org/apache/axiom/...

Author: veithen
Date: Sat Feb 25 12:22:37 2012
New Revision: 1293589

URL: http://svn.apache.org/viewvc?rev=1293589&view=rev
Log:
Introduced a well-defined and supported way to force namespace URI interning on XMLStreamReaders returned by getXMLStreamReader.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningNamespaceContextWrapper.java
      - copied unchanged from r1293587, webservices/axiom/branches/namespaceURIInterning/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningNamespaceContextWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningXMLStreamReaderWrapper.java
      - copied unchanged from r1293587, webservices/axiom/branches/namespaceURIInterning/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceURIInterningXMLStreamReaderWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithNamespaceURIInterning.java
      - copied unchanged from r1293587, webservices/axiom/branches/namespaceURIInterning/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithNamespaceURIInterning.java
Modified:
    webservices/commons/trunk/modules/axiom/   (props changed)
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java

Propchange: webservices/commons/trunk/modules/axiom/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Feb 25 12:22:37 2012
@@ -1 +1,2 @@
+/webservices/axiom/branches/namespaceURIInterning:1293148-1293587
 /webservices/axiom/branches/osgi-redesign:1180368-1180596

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java?rev=1293589&r1=1293588&r2=1293589&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java Sat Feb 25 12:22:37 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om;
 
+import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamReader;
 
@@ -27,9 +28,10 @@ import javax.xml.stream.XMLStreamReader;
  */
 public class OMXMLStreamReaderConfiguration {
     private boolean preserveNamespaceContext;
+    private boolean namespaceURIInterning;
 
     /**
-     * Determines whether strict namespace preservation is enabled. See
+     * Determine whether strict namespace preservation is enabled. See
      * {@link #setPreserveNamespaceContext(boolean)} for more information about this option.
      * 
      * @return the current value of this option
@@ -88,4 +90,33 @@ public class OMXMLStreamReaderConfigurat
     public void setPreserveNamespaceContext(boolean preserveNamespaceContext) {
         this.preserveNamespaceContext = preserveNamespaceContext;
     }
+
+    /**
+     * Determine whether namespace URIs returned by the {@link XMLStreamReader} should be interned.
+     * 
+     * @return the current value of this option
+     */
+    public boolean isNamespaceURIInterning() {
+        return namespaceURIInterning;
+    }
+
+    /**
+     * Specify whether namespace URIs returned by the {@link XMLStreamReader} should be interned.
+     * This applies to the return values of the following methods:
+     * <ul>
+     * <li>{@link XMLStreamReader#getAttributeNamespace(int)}
+     * <li>{@link XMLStreamReader#getNamespaceURI()}
+     * <li>{@link XMLStreamReader#getNamespaceURI(int)}
+     * <li>{@link XMLStreamReader#getNamespaceURI(String)}
+     * <li>{@link NamespaceContext#getNamespaceURI(String)} of the {@link NamespaceContext} instance
+     * returned by {@link XMLStreamReader#getNamespaceContext()}
+     * </ul>
+     * 
+     * @param namespaceURIInterning
+     *            the value to set for this option
+     * @see String#intern()
+     */
+    public void setNamespaceURIInterning(boolean namespaceURIInterning) {
+        this.namespaceURIInterning = namespaceURIInterning;
+    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java?rev=1293589&r1=1293588&r2=1293589&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java Sat Feb 25 12:22:37 2012
@@ -51,7 +51,7 @@ public final class OMContainerHelper {
         }
         
         // The om tree was built by hand and is already complete
-        OMXMLStreamReader reader = null;
+        OMXMLStreamReader reader;
         boolean done = container.isComplete();
         if ((builder == null) && done) {
             reader = new OMStAXWrapper(null, container, false, configuration.isPreserveNamespaceContext());
@@ -67,6 +67,10 @@ public final class OMContainerHelper {
             reader = new OMStAXWrapper(builder, container, cache, configuration.isPreserveNamespaceContext());
         }
         
+        if (configuration.isNamespaceURIInterning()) {
+            reader = new NamespaceURIInterningXMLStreamReaderWrapper(reader);
+        }
+        
         // 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

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1293589&r1=1293588&r2=1293589&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Sat Feb 25 12:22:37 2012
@@ -196,6 +196,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderNextTag(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory, true));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory, false));
+        addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithNamespaceURIInterning(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithoutCachingPartiallyBuilt(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithPreserveNamespaceContext(metaFactory));