ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1748040 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/ axiom-api/src/main/java/org/apache/axiom/om/ implem...
Date Sun, 12 Jun 2016 19:33:12 GMT
Author: veithen
Date: Sun Jun 12 19:33:12 2016
New Revision: 1748040

URL: http://svn.apache.org/viewvc?rev=1748040&view=rev
Log:
Add APIs to create XOP/MTOM builders from a (Source, MimePartProvider) pair.

Added:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/DummyLocation.java
      - copied, changed from r1748026, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/DummyLocation.java
Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/BuilderSpec.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
    webservices/axiom/trunk/implementations/fom-impl/pom.xml
    webservices/axiom/trunk/implementations/fom-impl/src/test/java/org/apache/axiom/fom/impl/OSGiITCase.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/xop/XOPRoundtripTest.java

Copied: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/DummyLocation.java
(from r1748026, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/DummyLocation.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/DummyLocation.java?p2=webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/DummyLocation.java&p1=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/DummyLocation.java&r1=1748026&r2=1748040&rev=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/DummyLocation.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/DummyLocation.java
Sun Jun 12 19:33:12 2016
@@ -16,8 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-package org.apache.axiom.util.stax;
+package org.apache.axiom.core.stream.stax.pull;
 
 import javax.xml.stream.Location;
 
@@ -27,10 +26,10 @@ import javax.xml.stream.Location;
  * {@link javax.xml.stream.XMLStreamReader} implementations that don't support
  * the concept of location.
  */
-public class DummyLocation implements Location {
-    public static final DummyLocation INSTANCE = new DummyLocation();
+class DummyLocation implements Location {
+    static final DummyLocation INSTANCE = new DummyLocation();
 
-    protected DummyLocation() {}
+    private DummyLocation() {}
     
     public int getLineNumber() {
         return -1;

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
Sun Jun 12 19:33:12 2016
@@ -854,8 +854,7 @@ public final class StAXPivot implements
 
     @Override
     public Location getLocation() {
-        // TODO Auto-generated method stub
-        return null;
+        return DummyLocation.INSTANCE;
     }
 
     @Override

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
Sun Jun 12 19:33:12 2016
@@ -73,6 +73,11 @@ public abstract class AbstractOMMetaFact
         return OM.createBuilder(nodeFactory, BuilderSpec.from(configuration, rootPart, mimePartProvider));
     }
 
+    @Override
+    public OMXMLParserWrapper createOMBuilder(Source rootPart, MimePartProvider mimePartProvider)
{
+        return OM.createBuilder(nodeFactory, BuilderSpec.from(StAXParserConfiguration.DEFAULT,
rootPart, mimePartProvider));
+    }
+
     public SOAPModelBuilder createStAXSOAPModelBuilder(XMLStreamReader parser) {
         return SOAP.createBuilder(nodeFactory, BuilderSpec.from(parser));
     }
@@ -94,4 +99,9 @@ public abstract class AbstractOMMetaFact
         }
         return builder;
     }
+
+    @Override
+    public SOAPModelBuilder createSOAPModelBuilder(Source rootPart, MimePartProvider mimePartProvider)
{
+        return SOAP.createBuilder(nodeFactory, BuilderSpec.from(StAXParserConfiguration.SOAP,
rootPart, mimePartProvider));
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/BuilderSpec.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/BuilderSpec.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/BuilderSpec.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/BuilderSpec.java
Sun Jun 12 19:33:12 2016
@@ -29,6 +29,7 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.axiom.core.stream.FilteredXmlInput;
@@ -153,6 +154,8 @@ final class BuilderSpec {
             is.setPublicId(streamSource.getPublicId());
             is.setSystemId(streamSource.getSystemId());
             return from(configuration, is);
+        } else if (source instanceof StAXSource) {
+            return from(((StAXSource)source).getXMLStreamReader());
         } else {
             try {
                 return new BuilderSpec(
@@ -184,6 +187,15 @@ final class BuilderSpec {
                 mimePartProvider instanceof Detachable ? (Detachable) mimePartProvider :
null);
     }
 
+    static BuilderSpec from(StAXParserConfiguration configuration, Source source, MimePartProvider
mimePartProvider) {
+        BuilderSpec spec = from(configuration, source);
+        return new BuilderSpec(
+                new FilteredXmlInput(
+                        spec.getInput(),
+                        new XOPDecodingFilter(mimePartProvider)),
+                spec.getDetachable());
+    }
+
     XmlInput getInput() {
         return input;
     }

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
Sun Jun 12 19:33:12 2016
@@ -153,6 +153,8 @@ public interface OMMetaFactory {
     OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration,
             InputSource rootPart, MimePartProvider mimePartProvider);
     
+    OMXMLParserWrapper createOMBuilder(Source rootPart, MimePartProvider mimePartProvider);
+    
     /**
      * Create an object model builder for SOAP that pulls events from a StAX stream reader.
The
      * implementation will select the appropriate {@link SOAPFactory} based on the namespace
URI of
@@ -207,4 +209,6 @@ public interface OMMetaFactory {
      */
     SOAPModelBuilder createSOAPModelBuilder(StAXParserConfiguration configuration,
             SOAPFactory soapFactory, InputSource rootPart, MimePartProvider mimePartProvider);
+    
+    SOAPModelBuilder createSOAPModelBuilder(Source rootPart, MimePartProvider mimePartProvider);
 }

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
Sun Jun 12 19:33:12 2016
@@ -31,6 +31,7 @@ import javax.xml.transform.sax.SAXSource
 import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
 import org.apache.axiom.mime.ContentType;
+import org.apache.axiom.mime.MimePartProvider;
 import org.apache.axiom.om.impl.builder.AttachmentsMimePartProvider;
 import org.apache.axiom.om.util.StAXParserConfiguration;
 import org.apache.axiom.soap.SOAPFactory;
@@ -470,6 +471,11 @@ public class OMXMLBuilderFactory {
                 new AttachmentsMimePartProvider(attachments));
     }
     
+    public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
+            Source rootPart, MimePartProvider mimePartProvider) {
+        return omFactory.getMetaFactory().createOMBuilder(rootPart, mimePartProvider);
+    }
+    
     /**
      * Create an object model builder for SOAP that pulls events from a StAX stream reader
and that
      * uses a particular Axiom implementation. The method will select the appropriate
@@ -659,4 +665,9 @@ public class OMXMLBuilderFactory {
         rootPart.setEncoding(contentType.getParameter("charset"));
         return rootPart;
     }
+    
+    public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory,
+            Source rootPart, MimePartProvider mimePartProvider) {
+        return metaFactory.createSOAPModelBuilder(rootPart, mimePartProvider);
+    }
 }

Modified: webservices/axiom/trunk/implementations/fom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/pom.xml?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/pom.xml (original)
+++ webservices/axiom/trunk/implementations/fom-impl/pom.xml Sun Jun 12 19:33:12 2016
@@ -172,6 +172,11 @@
                                     <artifactId>org.apache.servicemix.specs.stax-api-1.2</artifactId>
                                     <version>2.7.0</version>
                                 </artifact>
+                                <artifact>
+                                    <groupId>org.apache.servicemix.specs</groupId>
+                                    <artifactId>org.apache.servicemix.specs.jaxp-api-1.4</artifactId>
+                                    <version>2.7.0</version>
+                                </artifact>
                             </artifacts>
                         </configuration>
                     </execution>

Modified: webservices/axiom/trunk/implementations/fom-impl/src/test/java/org/apache/axiom/fom/impl/OSGiITCase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/test/java/org/apache/axiom/fom/impl/OSGiITCase.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/test/java/org/apache/axiom/fom/impl/OSGiITCase.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/test/java/org/apache/axiom/fom/impl/OSGiITCase.java
Sun Jun 12 19:33:12 2016
@@ -44,6 +44,7 @@ public class OSGiITCase {
         return options(
                 url("link:classpath:org.apache.geronimo.specs.geronimo-activation_1.1_spec.link"),
                 // TODO: this should no longer be necessary once we remove the dependency
on the Axiom API
+                url("link:classpath:org.apache.servicemix.specs.jaxp-api-1.4.link"),
                 url("link:classpath:org.apache.servicemix.specs.jaxb-api-2.2.link"),
                 url("link:classpath:org.apache.servicemix.specs.stax-api-1.2.link"),
                 url("link:classpath:stax2-api.link"),

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/xop/XOPRoundtripTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/xop/XOPRoundtripTest.java?rev=1748040&r1=1748039&r2=1748040&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/xop/XOPRoundtripTest.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/xop/XOPRoundtripTest.java
Sun Jun 12 19:33:12 2016
@@ -21,18 +21,16 @@ package org.apache.axiom.ts.om.xop;
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stax.StAXSource;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.testutils.activation.TestDataSource;
 import org.apache.axiom.ts.AxiomTestCase;
-import org.apache.axiom.util.stax.xop.ContentIDGenerator;
-import org.apache.axiom.util.stax.xop.OptimizationPolicy;
-import org.apache.axiom.util.stax.xop.XOPDecodingStreamReader;
-import org.apache.axiom.util.stax.xop.XOPEncodingStreamReader;
 
 public class XOPRoundtripTest extends AxiomTestCase {
     public XOPRoundtripTest(OMMetaFactory metaFactory) {
@@ -44,11 +42,11 @@ public class XOPRoundtripTest extends Ax
         DataHandler dh = new DataHandler(new TestDataSource('x', Runtime.getRuntime().maxMemory()));
         OMElement element1 = factory.createOMElement(new QName("test"));
         element1.addChild(factory.createOMText(dh, true));
-        XMLStreamReader originalReader = element1.getXMLStreamReader();
-        XOPEncodingStreamReader encodedReader = new XOPEncodingStreamReader(originalReader,
-                ContentIDGenerator.DEFAULT, OptimizationPolicy.DEFAULT);
-        XMLStreamReader decodedReader = new XOPDecodingStreamReader(encodedReader, encodedReader);
-        OMElement element2 = OMXMLBuilderFactory.createStAXOMBuilder(factory, decodedReader).getDocumentElement();
+        XOPEncoded<XMLStreamReader> xopEncodedStream = element1.getXOPEncodedStreamReader(true);
+        OMElement element2 = OMXMLBuilderFactory.createOMBuilder(
+                factory,
+                new StAXSource(xopEncodedStream.getRootPart()),
+                xopEncodedStream.getMimePartProvider()).getDocumentElement();
         OMText child = (OMText)element2.getFirstOMChild();
         assertNotNull(child);
         assertTrue(child.isBinary());



Mime
View raw message