ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1748020 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/ axiom-api/ axiom-api/src/main/java/org/apache/axiom/om/ axiom-jaxb/src/...
Date Sun, 12 Jun 2016 15:17:13 GMT
Author: veithen
Date: Sun Jun 12 15:17:13 2016
New Revision: 1748020

URL: http://svn.apache.org/viewvc?rev=1748020&view=rev
Log:
Add JAXB unmarshalling support directly to OMContainer.

Added:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/AttachmentUnmarshallerImpl.java
      - copied, changed from r1747986, webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/util/jaxb/AttachmentUnmarshallerImpl.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/UnmarshallerConfigurator.java
  (with props)
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
    webservices/axiom/trunk/axiom-api/pom.xml
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
    webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.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/systests/osgi-tests/src/test/java/org/apache/axiom/test/UsesConstraintsTest.java

Copied: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/AttachmentUnmarshallerImpl.java
(from r1747986, webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/util/jaxb/AttachmentUnmarshallerImpl.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/AttachmentUnmarshallerImpl.java?p2=webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/AttachmentUnmarshallerImpl.java&p1=webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/util/jaxb/AttachmentUnmarshallerImpl.java&r1=1747986&r2=1748020&rev=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/util/jaxb/AttachmentUnmarshallerImpl.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/jaxb/AttachmentUnmarshallerImpl.java
Sun Jun 12 15:17:13 2016
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.util.jaxb;
+package org.apache.axiom.om.impl.jaxb;
 
 import java.io.IOException;
 
@@ -26,10 +26,10 @@ import javax.xml.bind.attachment.Attachm
 import org.apache.axiom.mime.MimePartProvider;
 import org.apache.axiom.util.stax.xop.XOPUtils;
 
-final class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller {
+public final class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller {
     private final MimePartProvider mimePartProvider;
     
-    AttachmentUnmarshallerImpl(MimePartProvider mimePartProvider) {
+    public AttachmentUnmarshallerImpl(MimePartProvider mimePartProvider) {
         this.mimePartProvider = mimePartProvider;
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
Sun Jun 12 15:17:13 2016
@@ -24,6 +24,10 @@ import java.io.Writer;
 import java.util.Iterator;
 
 import javax.activation.DataHandler;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
@@ -58,6 +62,7 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
+import org.apache.axiom.om.UnmarshallerConfigurator;
 import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.om.impl.OMMultipartWriter;
 import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
@@ -68,6 +73,7 @@ import org.apache.axiom.om.impl.intf.Axi
 import org.apache.axiom.om.impl.intf.AxiomContainer;
 import org.apache.axiom.om.impl.intf.AxiomElement;
 import org.apache.axiom.om.impl.intf.OMFactoryEx;
+import org.apache.axiom.om.impl.jaxb.AttachmentUnmarshallerImpl;
 import org.apache.axiom.om.impl.stream.NamespaceContextPreservationFilterHandler;
 import org.apache.axiom.om.impl.stream.XmlDeclarationRewriterHandler;
 import org.apache.axiom.om.impl.stream.XsiTypeFilterHandler;
@@ -373,4 +379,24 @@ public aspect AxiomContainerSupport {
             builder.close();
         }
     }
+
+    public final Object AxiomContainer.unmarshal(JAXBContext context, UnmarshallerConfigurator
configurator, boolean preserve) throws JAXBException {
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        if (configurator != null) {
+            configurator.configure(unmarshaller);
+        }
+        XOPEncoded<XMLStreamReader> xopEncodedStream = getXOPEncodedStreamReader(preserve);
+        unmarshaller.setAttachmentUnmarshaller(new AttachmentUnmarshallerImpl(xopEncodedStream.getMimePartProvider()));
+        return unmarshaller.unmarshal(xopEncodedStream.getRootPart());
+    }
+
+    public final <T> JAXBElement<T> AxiomContainer.unmarshal(JAXBContext context,
UnmarshallerConfigurator configurator, Class<T> declaredType, boolean preserve) throws
JAXBException {
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        if (configurator != null) {
+            configurator.configure(unmarshaller);
+        }
+        XOPEncoded<XMLStreamReader> xopEncodedStream = getXOPEncodedStreamReader(preserve);
+        unmarshaller.setAttachmentUnmarshaller(new AttachmentUnmarshallerImpl(xopEncodedStream.getMimePartProvider()));
+        return unmarshaller.unmarshal(xopEncodedStream.getRootPart(), declaredType);
+    }
 }

Modified: webservices/axiom/trunk/axiom-api/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/pom.xml?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/pom.xml (original)
+++ webservices/axiom/trunk/axiom-api/pom.xml Sun Jun 12 15:17:13 2016
@@ -221,7 +221,6 @@
                         <Import-Package>
                             org.jaxen.*;resolution:=optional,
                             org.codehaus.stax2;resolution:=optional,
-                            javax.xml.bind.*;resolution:=optional,
                             *
                         </Import-Package>
                         <Bundle-Activator>org.apache.axiom.locator.Activator</Bundle-Activator>

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Sun
Jun 12 15:17:13 2016
@@ -19,6 +19,9 @@
 
 package org.apache.axiom.om;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
@@ -413,4 +416,36 @@ public interface OMContainer extends OMS
      * @return an XOP encoded representation of this information item
      */
     XOPEncoded<XMLStreamReader> getXOPEncodedStreamReader(boolean cache);
+    
+    /**
+     * Unmarshall the information item using JAXB.
+     * 
+     * @param context
+     *            the JAXB context
+     * @param configurator
+     *            custom unmarshaller settings to apply; may be {@code null}
+     * @param preserve
+     *            specifies whether the content of the information item should be preserved
+     * @return the unmarshalled object
+     * @throws JAXBException
+     *             if an error occurred while unmarshalling
+     */
+    Object unmarshal(JAXBContext context, UnmarshallerConfigurator configurator, boolean
preserve) throws JAXBException;
+    
+    /**
+     * Unmarshall the information item using JAXB.
+     * 
+     * @param context
+     *            the JAXB context
+     * @param configurator
+     *            custom unmarshaller settings to apply; may be {@code null}
+     * @param declaredType
+     *            a JAXB mapped class to hold the XML data.
+     * @param preserve
+     *            specifies whether the content of the information item should be preserved
+     * @return the unmarshalled object
+     * @throws JAXBException
+     *             if an error occurred while unmarshalling
+     */
+    <T> JAXBElement<T> unmarshal(JAXBContext context, UnmarshallerConfigurator
configurator, Class<T> declaredType, boolean preserve) throws JAXBException;
 }

Added: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/UnmarshallerConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/UnmarshallerConfigurator.java?rev=1748020&view=auto
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/UnmarshallerConfigurator.java
(added)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/UnmarshallerConfigurator.java
Sun Jun 12 15:17:13 2016
@@ -0,0 +1,37 @@
+/*
+ * 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 javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+/**
+ * Interface used to apply custom settings to an {@link Unmarshaller}.
+ */
+public interface UnmarshallerConfigurator {
+    /**
+     * Apply settings to the given unmarshaller.
+     * 
+     * @param unmarshaller
+     *            the unmarshaller to configure
+     * @throws JAXBException
+     *             if the unmarshaller throws an exception
+     */
+    void configure(Unmarshaller unmarshaller) throws JAXBException;
+}

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

Modified: webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java
(original)
+++ webservices/axiom/trunk/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java
Sun Jun 12 15:17:13 2016
@@ -20,10 +20,10 @@ package org.apache.axiom.om.util.jaxb;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.util.jaxb.UnmarshallerAdapter;
+import org.apache.axiom.om.UnmarshallerConfigurator;
 
 /**
  * Contains utility methods that integrate JAXB with Axiom.
@@ -44,12 +44,10 @@ public final class JAXBUtils {
      * @return the JAXB object
      * @throws JAXBException
      *             if an error occurs while unmarshalling
+     * @deprecated Use {@link OMContainer#unmarshal(JAXBContext, UnmarshallerConfigurator,
boolean)}
+     *             instead.
      */
     public static Object unmarshal(JAXBContext context, OMElement element, boolean cache)
throws JAXBException {
-        UnmarshallerAdapter adapter = org.apache.axiom.util.jaxb.JAXBUtils.getUnmarshallerAdapter(
-                element.getXMLStreamReader(cache));
-        Unmarshaller unmarshaller = context.createUnmarshaller();
-        unmarshaller.setAttachmentUnmarshaller(adapter.getAttachmentUnmarshaller());
-        return unmarshaller.unmarshal(adapter.getReader());
+        return element.unmarshal(context, null, cache);
     }
 }

Modified: webservices/axiom/trunk/implementations/fom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/pom.xml?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/pom.xml (original)
+++ webservices/axiom/trunk/implementations/fom-impl/pom.xml Sun Jun 12 15:17:13 2016
@@ -161,6 +161,18 @@
                                 <scope>test</scope>
                                 <useProjectArtifact>true</useProjectArtifact>
                             </dependencySet>
+                            <artifacts>
+                                <artifact>
+                                    <groupId>org.apache.servicemix.specs</groupId>
+                                    <artifactId>org.apache.servicemix.specs.jaxb-api-2.2</artifactId>
+                                    <version>2.7.0</version>
+                                </artifact>
+                                <artifact>
+                                    <groupId>org.apache.servicemix.specs</groupId>
+                                    <artifactId>org.apache.servicemix.specs.stax-api-1.2</artifactId>
+                                    <version>2.7.0</version>
+                                </artifact>
+                            </artifacts>
                         </configuration>
                     </execution>
                 </executions>

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=1748020&r1=1748019&r2=1748020&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 15:17:13 2016
@@ -43,6 +43,11 @@ public class OSGiITCase {
     public static Option[] configuration() {
         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.jaxb-api-2.2.link"),
+                url("link:classpath:org.apache.servicemix.specs.stax-api-1.2.link"),
+                url("link:classpath:stax2-api.link"),
+                url("link:classpath:woodstox-core-asl.link"),
                 url("link:classpath:org.apache.commons.codec.link"),
                 url("link:classpath:org.apache.abdera.core.link"),
                 url("link:classpath:org.apache.abdera.i18n.link"),

Modified: webservices/axiom/trunk/systests/osgi-tests/src/test/java/org/apache/axiom/test/UsesConstraintsTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/osgi-tests/src/test/java/org/apache/axiom/test/UsesConstraintsTest.java?rev=1748020&r1=1748019&r2=1748020&view=diff
==============================================================================
--- webservices/axiom/trunk/systests/osgi-tests/src/test/java/org/apache/axiom/test/UsesConstraintsTest.java
(original)
+++ webservices/axiom/trunk/systests/osgi-tests/src/test/java/org/apache/axiom/test/UsesConstraintsTest.java
Sun Jun 12 15:17:13 2016
@@ -61,8 +61,8 @@ public class UsesConstraintsTest {
     static class Listener implements FrameworkListener {
         private final Pattern regex = Pattern.compile(
                 "Uses constraint violation\\. Unable to resolve .* testbundle. \\[.*\\] because
it is exposed to "
-                + "package 'javax\\.xml\\.stream' from .* org\\.apache\\.felix\\.framework
.* and "
-                + "org\\.apache\\.servicemix\\.specs\\.stax-api-1.0 .* via two dependency
chains\\."
+                + "package 'javax\\.xml\\.stream' from .* org\\.apache\\.servicemix\\.specs\\.stax-api-1.0
.* and "
+                + "org\\.apache\\.felix\\.framework .* via two dependency chains\\."
                 + ".*package=org\\.apache\\.axiom\\.om.*", Pattern.DOTALL); 
         private final CountDownLatch latch = new CountDownLatch(1);
         private boolean gotExpectedError;



Mime
View raw message