ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1196397 - 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/builder/ axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/factory/ ...
Date Tue, 01 Nov 2011 23:40:05 GMT
Author: veithen
Date: Tue Nov  1 23:40:05 2011
New Revision: 1196397

URL: http://svn.apache.org/viewvc?rev=1196397&view=rev
Log:
AXIOM-353: Added methods to create XOP aware builders.

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/OMXMLBuilderFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.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=1196397&r1=1196396&r2=1196397&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  1 23:40:05 2011
@@ -117,6 +117,23 @@ public interface OMMetaFactory {
     OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Source source);
     
     /**
+     * Create an XOP aware object model builder.
+     * 
+     * @param configuration
+     *            the parser configuration to use
+     * @param omFactory
+     *            The object model factory to use. This factory must be obtained from the
same
+     *            {@link OMMetaFactory} instance as the one used to invoke this method.
+     * @param rootPart
+     *            the source of the root part of the XOP message
+     * @param mimePartProvider
+     *            the provider from which MIME parts referenced in the root part will be
retrieved
+     * @return the builder
+     */
+    OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration,
+            OMFactory omFactory, InputSource 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
      * the SOAP envelope.

Modified: 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=1196397&r1=1196396&r2=1196397&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
Tue Nov  1 23:40:05 2011
@@ -289,6 +289,52 @@ public class OMXMLBuilderFactory {
     }
     
     /**
+     * Create an XOP aware model builder from the provided {@link Attachments} object and
with a
+     * given parser configuration.
+     * 
+     * @param configuration
+     *            the parser configuration to use
+     * @param attachments
+     *            an {@link Attachments} object that must have been created from an input
stream
+     * @return the builder
+     * @throws OMException
+     *             if an error occurs while processing the content type information from
the
+     *             {@link Attachments} object
+     */
+    public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration,
Attachments attachments) {
+        return createOMBuilder(OMAbstractFactory.getMetaFactory().getOMFactory(), configuration,
attachments);
+    }
+    
+    /**
+     * Create an XOP aware model builder from the provided {@link Attachments} object using
a
+     * specified object model factory and with a given parser configuration.
+     * 
+     * @param omFactory
+     *            the object model factory to use
+     * @param configuration
+     *            the parser configuration to use
+     * @param attachments
+     *            an {@link Attachments} object that must have been created from an input
stream
+     * @return the builder
+     * @throws OMException
+     *             if an error occurs while processing the content type information from
the
+     *             {@link Attachments} object
+     */
+    public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
+            StAXParserConfiguration configuration, Attachments attachments) {
+        ContentType contentType;
+        try {
+            contentType = new ContentType(attachments.getRootPartContentType());
+        } catch (ParseException ex) {
+            throw new OMException(ex);
+        }
+        InputSource rootPart = new InputSource(attachments.getRootPartInputStream());
+        rootPart.setEncoding(contentType.getParameter("charset"));
+        return omFactory.getMetaFactory().createOMBuilder(configuration, omFactory,
+                rootPart, new OMAttachmentAccessorMimePartProvider(attachments));
+    }
+    
+    /**
      * Create an object model builder for SOAP that pulls events from a StAX stream reader.
      * The method will select the appropriate {@link SOAPFactory}
      * based on the namespace URI of the SOAP envelope.

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java?rev=1196397&r1=1196396&r2=1196397&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
Tue Nov  1 23:40:05 2011
@@ -24,6 +24,7 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.util.stax.xop.MimePartProvider;
 import org.apache.axiom.util.stax.xop.XOPDecodingStreamReader;
 
 import javax.activation.DataHandler;
@@ -102,6 +103,12 @@ public class XOPAwareStAXOMBuilder 
         this.attachments = attachments;
     }
 
+    public XOPAwareStAXOMBuilder(OMFactory omFactory, XMLStreamReader reader,
+            MimePartProvider mimePartProvider) {
+        super(omFactory, new XOPDecodingStreamReader(reader, mimePartProvider));
+        attachments = null;
+    }
+
     public DataHandler getDataHandler(String blobContentID) throws OMException {
         return attachments.getDataHandler(blobContentID);
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.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/factory/AbstractOMMetaFactory.java?rev=1196397&r1=1196396&r2=1196397&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
Tue Nov  1 23:40:05 2011
@@ -29,6 +29,7 @@ import org.apache.axiom.om.OMMetaFactory
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.builder.SAXOMXMLParserWrapper;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
 import org.apache.axiom.om.util.StAXParserConfiguration;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAPFactory;
@@ -88,6 +89,14 @@ public abstract class AbstractOMMetaFact
         }
     }
 
+    public OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration,
+            OMFactory omFactory, InputSource rootPart, MimePartProvider mimePartProvider)
{
+        XOPAwareStAXOMBuilder builder = new XOPAwareStAXOMBuilder(omFactory, createXMLStreamReader(
+                configuration, rootPart), mimePartProvider);
+        builder.releaseParserOnClose(true);
+        return builder;
+    }
+
     public SOAPModelBuilder createStAXSOAPModelBuilder(XMLStreamReader parser) {
         StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(this, parser);
         builder.releaseParserOnClose(true);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=1196397&r1=1196396&r2=1196397&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
Tue Nov  1 23:40:05 2011
@@ -24,10 +24,11 @@ import org.apache.axiom.om.MIMEResource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.om.impl.MIMEOutputUtils;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
-import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
+import org.apache.axiom.om.util.StAXParserConfiguration;
 import org.apache.axiom.soap.SOAPModelBuilder;
 
 import java.io.ByteArrayInputStream;
@@ -66,9 +67,8 @@ public class AttachmentsTest extends Abs
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, oof);
         
-        XOPAwareStAXOMBuilder builder = 
-            new XOPAwareStAXOMBuilder(attachments.getRootPartInputStream(),
-                                      attachments);
+        OMXMLParserWrapper builder =
+            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
         OMElement om = builder.getDocumentElement();
         om.serialize(writer);
         om.close(false);
@@ -83,8 +83,7 @@ public class AttachmentsTest extends Abs
                         Boolean.TRUE);
         writer = new MTOMXMLStreamWriter(baos, oof);
         builder = 
-            new XOPAwareStAXOMBuilder(attachments.getRootPartInputStream(),
-                                      attachments);
+            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
         om = builder.getDocumentElement();
         om.serialize(writer);
         om.close(false);
@@ -106,8 +105,7 @@ public class AttachmentsTest extends Abs
                         Boolean.FALSE);
         writer = new MTOMXMLStreamWriter(baos, oof);
         builder = 
-            new XOPAwareStAXOMBuilder(attachments2.getRootPartInputStream(),
-                                      attachments2);
+            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
         om = builder.getDocumentElement();
         om.serialize(writer);
         om.close(false);
@@ -122,8 +120,7 @@ public class AttachmentsTest extends Abs
                         Boolean.TRUE);
         writer = new MTOMXMLStreamWriter(baos, oof);
         builder = 
-            new XOPAwareStAXOMBuilder(attachments2.getRootPartInputStream(),
-                                      attachments2);
+            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
         om = builder.getDocumentElement();
         om.serialize(writer);
         om.close(false);



Mime
View raw message