ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1040821 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/main/java/org/apache/axiom/om/impl/ axiom-api/src/test/java/org/apache/axiom/om/ axiom-api/src/test/java/org/apache/a...
Date Tue, 30 Nov 2010 23:16:49 GMT
Author: veithen
Date: Tue Nov 30 23:16:49 2010
New Revision: 1040821

URL: http://svn.apache.org/viewvc?rev=1040821&view=rev
Log:
Started to design an API as described in AXIOM-353. It keeps the original name (OMXMLBuilderFactory),
but is placed into the right package and takes into account the OMMetaFactory stuff.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
  (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
Tue Nov 30 23:16:49 2010
@@ -19,6 +19,11 @@
 
 package org.apache.axiom.om;
 
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.axiom.soap.SOAPFactory;
 
 /**
@@ -57,4 +62,33 @@ public interface OMMetaFactory {
      * @return the OM factory instance
      */
     SOAPFactory getSOAP12Factory();
+    
+    /**
+     * Create an object model builder for plain XML that pulls events from a StAX stream
reader.
+     * 
+     * @param parser
+     *            the stream reader to read the XML data from
+     * @return the builder
+     */
+    OMXMLParserWrapper createStAXOMBuilder(XMLStreamReader parser);
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided input
+     * stream.
+     * 
+     * @param in
+     *            the input stream representing the XML document
+     * @return the builder
+     */
+    OMXMLParserWrapper createOMBuilder(InputStream in);
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided character
+     * stream.
+     * 
+     * @param in
+     *            the character stream representing the XML document
+     * @return the builder
+     */
+    OMXMLParserWrapper createOMBuilder(Reader in);
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java?rev=1040821&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
Tue Nov 30 23:16:49 2010
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Provides static factory methods to create various kinds of object model builders from
different
+ * types of input sources. The methods defined by this class are the starting point to parse
XML
+ * documents into Axiom trees.
+ */
+public class OMXMLBuilderFactory {
+    private OMXMLBuilderFactory() {}
+    
+    /**
+     * Create an object model builder for plain XML that pulls events from a StAX stream
reader.
+     * 
+     * @param parser
+     *            the stream reader to read the XML data from
+     * @return the builder
+     */
+    public static OMXMLParserWrapper createStAXOMBuilder(XMLStreamReader parser) {
+        return OMAbstractFactory.getMetaFactory().createStAXOMBuilder(parser);
+    }
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided input
+     * stream.
+     * 
+     * @param in
+     *            the input stream representing the XML document
+     * @return the builder
+     */
+    public static OMXMLParserWrapper createOMBuilder(InputStream in) {
+        return OMAbstractFactory.getMetaFactory().createOMBuilder(in);
+    }
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided character
+     * stream.
+     * 
+     * @param in
+     *            the character stream representing the XML document
+     * @return the builder
+     */
+    public static OMXMLParserWrapper createOMBuilder(Reader in) {
+        return OMAbstractFactory.getMetaFactory().createOMBuilder(in);
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
Tue Nov 30 23:16:49 2010
@@ -66,6 +66,13 @@ public interface OMXMLParserWrapper {
     /** @return Returns the complete status. */
     boolean isCompleted();
 
+    /**
+     * Get the document being built by this builder.
+     * 
+     * @return the {@link OMDocument} instance
+     */
+    OMDocument getDocument();
+    
     /** @return Returns the document element. */
     OMElement getDocumentElement();
 

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java?rev=1040821&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
Tue Nov 30 23:16:49 2010
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * Base class for {@link OMMetaFactory} implementations that make use of the standard builders
+ * ({@link org.apache.axiom.om.impl.builder.StAXOMBuilder} and its subclasses).
+ */
+public abstract class AbstractOMMetaFactory implements OMMetaFactory {
+    public OMXMLParserWrapper createStAXOMBuilder(XMLStreamReader parser) {
+        return new StAXOMBuilder(getOMFactory(), parser);
+    }
+
+    public OMXMLParserWrapper createOMBuilder(InputStream in) {
+        try {
+            return new StAXOMBuilder(getOMFactory(), StAXUtils.createXMLStreamReader(in));
+        } catch (XMLStreamException ex) {
+            throw new OMException(ex);
+        }
+    }
+
+    public OMXMLParserWrapper createOMBuilder(Reader in) {
+        try {
+            return new StAXOMBuilder(getOMFactory(), StAXUtils.createXMLStreamReader(in));
+        } catch (XMLStreamException ex) {
+            throw new OMException(ex);
+        }
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
Tue Nov 30 23:16:49 2010
@@ -32,8 +32,6 @@ import javax.activation.DataSource;
 import javax.activation.URLDataSource;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
 import org.custommonkey.xmlunit.XMLTestCase;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;
@@ -93,14 +91,7 @@ public abstract class AbstractTestCase
     }
     
     public OMElement getTestResourceAsElement(OMMetaFactory omMetaFactory, String relativePath)
{
-        try {
-            return new StAXOMBuilder(omMetaFactory.getOMFactory(),
-                    StAXUtils.createXMLStreamReader(
-                            getTestResource(relativePath))).getDocumentElement();
-        } catch (Exception ex) {
-            fail("Unable to load test file " + relativePath + ": " + ex.getMessage());
-            return null; // Make compiler happy
-        }
+        return omMetaFactory.createOMBuilder(getTestResource(relativePath)).getDocumentElement();
     }
     
     public static String[] getConformanceTestFiles() {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
Tue Nov 30 23:16:49 2010
@@ -19,13 +19,9 @@
 
 package org.apache.axiom.om;
 
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.commons.io.input.CountingInputStream;
 
-import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import java.io.ByteArrayOutputStream;
 import java.io.StringReader;
 import java.util.Iterator;
@@ -102,15 +98,7 @@ public class OMDocumentTestBase extends 
     }
 
     private OMDocument getSampleOMDocument(String xml) {
-        try {
-            XMLStreamReader xmlStreamReader =
-                    StAXUtils.createXMLStreamReader(new StringReader(xml));
-            StAXOMBuilder builder =
-                    new StAXOMBuilder(omMetaFactory.getOMFactory(), xmlStreamReader);
-            return builder.getDocument();
-        } catch (XMLStreamException e) {
-            throw new UnsupportedOperationException();
-        }
+        return omMetaFactory.createOMBuilder(new StringReader(xml)).getDocument();
     }
 
 //    private OMDocument getSampleOMDocument() {
@@ -131,8 +119,7 @@ public class OMDocumentTestBase extends 
     public void testBuild() throws Exception {
         CountingInputStream in = new CountingInputStream(getTestResource(
                 TestConstants.REALLY_BIG_MESSAGE));
-        OMDocument doc = new StAXOMBuilder(omMetaFactory.getOMFactory(),
-                XMLInputFactory.newInstance().createXMLStreamReader(in)).getDocument();
+        OMDocument doc = omMetaFactory.createOMBuilder(in).getDocument();
         assertFalse(doc.isComplete());
         int countBeforeBuild = in.getCount();
         doc.build();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
Tue Nov 30 23:16:49 2010
@@ -25,11 +25,8 @@ import java.util.Iterator;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.AXIOMUtil;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAP11Constants;
 
 public abstract class OMElementTestBase extends AbstractTestCase {
@@ -476,10 +473,9 @@ public abstract class OMElementTestBase 
                 elem);
         String xml = elem.toString();
 
-        XMLStreamReader reader = StAXUtils.createXMLStreamReader(
+        OMXMLParserWrapper builder = omMetaFactory.createOMBuilder(
                 new ByteArrayInputStream(xml.getBytes()));
 
-        StAXOMBuilder builder = new StAXOMBuilder(omMetaFactory.getOMFactory(), reader);
         builder.getDocumentElement().build();
 
         // The StAX implementation may or may not have a trailing blank in the tag

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java
Tue Nov 30 23:16:49 2010
@@ -33,7 +33,6 @@ import org.apache.axiom.om.OMMetaFactory
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.AXIOMUtil;
 import org.apache.axiom.om.util.StAXParserConfiguration;
 import org.apache.axiom.om.util.StAXUtils;
@@ -53,8 +52,7 @@ public class OMStAXWrapperTestBase exten
         // reported). This is not the default for Woodstox (see WSTX-140).
         XMLStreamReader reader = StAXUtils.createXMLStreamReader(StAXParserConfiguration.NON_COALESCING,
is);
         
-        OMFactory omfactory = omMetaFactory.getOMFactory();
-        OMElement element = new StAXOMBuilder(omfactory, reader).getDocumentElement();
+        OMElement element = omMetaFactory.createStAXOMBuilder(reader).getDocumentElement();
         
         // Build the element so we have a full StAX tree
         element.build();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java
Tue Nov 30 23:16:49 2010
@@ -20,7 +20,7 @@
 package org.apache.axiom.om.impl.dom.factory;
 
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.impl.AbstractOMMetaFactory;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
@@ -36,7 +36,7 @@ import org.apache.axiom.soap.impl.dom.so
  * @scr.service interface="org.apache.axiom.om.OMMetaFactory"
  * @scr.property name="implementationName" type="String" value="doom"
  */
-public class OMDOMMetaFactory implements OMMetaFactory {
+public class OMDOMMetaFactory extends AbstractOMMetaFactory {
     public OMFactory getOMFactory() {
         return new OMDOMFactory();
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java?rev=1040821&r1=1040820&r2=1040821&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java
Tue Nov 30 23:16:49 2010
@@ -20,7 +20,7 @@
 package org.apache.axiom.om.impl.llom.factory;
 
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.impl.AbstractOMMetaFactory;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
@@ -36,7 +36,7 @@ import org.apache.axiom.soap.impl.llom.s
  * @scr.service interface="org.apache.axiom.om.OMMetaFactory"
  * @scr.property name="implementationName" type="String" value="llom"
  */
-public class OMLinkedListMetaFactory implements OMMetaFactory {
+public class OMLinkedListMetaFactory extends AbstractOMMetaFactory {
     private final OMFactory omFactory = new OMLinkedListImplFactory();
     private final SOAPFactory soap11Factory = new SOAP11Factory();
     private final SOAPFactory soap12Factory = new SOAP12Factory();



Mime
View raw message