cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/2] cxf git commit: [CXF-6481] Update to use latest snapshot version of bug986 xjc plugins Set the eventHandler for the unmarshallers to null so we get a proper error if something isn't working as expected
Date Wed, 08 Jul 2015 20:40:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master e6fb0d47f -> 58d5200bd


[CXF-6481] Update to use latest snapshot version of bug986 xjc plugins
Set the eventHandler for the unmarshallers to null so we get a proper error if something isn't
working as expected


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/81f0b461
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/81f0b461
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/81f0b461

Branch: refs/heads/master
Commit: 81f0b461d662eccd23ac5ade7349eecdc0316ddf
Parents: e6fb0d4
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Jul 8 15:59:33 2015 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Jul 8 16:00:45 2015 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/common/jaxb/JAXBUtils.java   | 17 ++++++++++++-
 .../AbstractBPBeanDefinitionParser.java         |  1 +
 .../jsse/TLSClientParametersConfig.java         |  8 +++---
 .../spring/AbstractBeanDefinitionParser.java    |  1 +
 .../configuration/spring/JAXBBeanFactory.java   | 26 +++++++++-----------
 .../cxf/ws/addressing/VersionTransformer.java   |  1 +
 pom.xml                                         |  2 +-
 rt/transports/http-jetty/pom.xml                |  6 +++++
 .../JettyHTTPServerEngineFactoryHolder.java     |  8 +++---
 .../apache/cxf/ws/addressing/soap/MAPCodec.java |  1 +
 .../builder/jaxb/JaxbAssertionBuilder.java      |  4 ++-
 11 files changed, 48 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index fe3d2ed..f4e4b54 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -183,6 +183,7 @@ public final class JAXBUtils {
     public static Object unmarshall(JAXBContext c, Element e) throws JAXBException {
         Unmarshaller u = c.createUnmarshaller();
         try {
+            u.setEventHandler(null);
             return u.unmarshal(e);
         } finally {
             closeUnmarshaller(u);
@@ -191,6 +192,7 @@ public final class JAXBUtils {
     public static <T> JAXBElement<T> unmarshall(JAXBContext c, Element e, Class<T>
cls) throws JAXBException {
         Unmarshaller u = c.createUnmarshaller();
         try {
+            u.setEventHandler(null);
             return u.unmarshal(e, cls);
         } finally {
             closeUnmarshaller(u);
@@ -199,20 +201,33 @@ public final class JAXBUtils {
     public static Object unmarshall(JAXBContext c, Source s) throws JAXBException {
         Unmarshaller u = c.createUnmarshaller();
         try {
+            u.setEventHandler(null);
             return u.unmarshal(s);
         } finally {
             closeUnmarshaller(u);
         }
     }
-    public static <T> JAXBElement<T> unmarshall(JAXBContext c, XMLStreamReader
reader,
+    public static <T> JAXBElement<T> unmarshall(JAXBContext c,
+                                                XMLStreamReader reader,
                                                 Class<T> cls) throws JAXBException
{
         Unmarshaller u = c.createUnmarshaller();
         try {
+            u.setEventHandler(null);
             return u.unmarshal(reader, cls);
         } finally {
             closeUnmarshaller(u);
         }
     }
+    public static Object unmarshall(JAXBContext c,
+                                    XMLStreamReader reader) throws JAXBException {
+        Unmarshaller u = c.createUnmarshaller();
+        try {
+            u.setEventHandler(null);
+            return u.unmarshal(reader);
+        } finally {
+            closeUnmarshaller(u);
+        }
+    }
     
     public static String builtInTypeToJavaType(String type) {
         return BUILTIN_DATATYPES_MAP.get(type);

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
index c211c8c..1e34cf0 100644
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -378,6 +378,7 @@ public abstract class AbstractBPBeanDefinitionParser {
 
             } catch (Exception ex) {                
                 u = getContext(c).createUnmarshaller();
+                u.setEventHandler(null);
                 Object obj;
                 if (c != null) {
                     obj = u.unmarshal(data, c);

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
index 7df3e05..e67571b 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
@@ -29,7 +29,6 @@ import javax.net.ssl.TrustManager;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
@@ -141,10 +140,10 @@ public final class TLSClientParametersConfig {
         
         StringReader reader = new StringReader(s);
         XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
-        Unmarshaller u = null;
         try {
-            u = getContext().createUnmarshaller();
-            JAXBElement<TLSClientParametersType> type = u.unmarshal(data, TLSClientParametersType.class);
+            JAXBElement<TLSClientParametersType> type = JAXBUtils.unmarshall(getContext(),

+                                                                             data,
+                                                                             TLSClientParametersType.class);
             TLSClientParametersType cpt = type.getValue();
             return createTLSClientParametersFromType(cpt);
         } catch (RuntimeException e) {
@@ -157,7 +156,6 @@ public final class TLSClientParametersConfig {
             } catch (XMLStreamException ex) {
                 throw new RuntimeException(ex);
             }
-            JAXBUtils.closeUnmarshaller(u);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
index d43eae0..e6e55de 100644
--- a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
@@ -358,6 +358,7 @@ public abstract class AbstractBeanDefinitionParser
                 bean.addPropertyValue(propertyName, jaxbbean.getBeanDefinition());
             } catch (Exception ex) {
                 u = getContext(c).createUnmarshaller();
+                u.setEventHandler(null);
                 Object obj;
                 if (c != null) {
                     obj = u.unmarshal(data, c);

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java b/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
index 9e4efc9..9c606df 100644
--- a/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
+++ b/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
@@ -24,7 +24,6 @@ import java.io.StringReader;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
@@ -39,25 +38,25 @@ public final class JAXBBeanFactory {
         //nothing
     }
     
-    public static Object createJAXBBean(JAXBContext context, 
+    public static <T> T createJAXBBean(JAXBContext context, 
                                         String s,
-                                        Class<?> c) {
+                                        Class<T> c) {
         
         StringReader reader = new StringReader(s);
         XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
-        Unmarshaller u = null;
         try {
-            Object obj;
-            u = context.createUnmarshaller();
+            
+            T obj = null;
             if (c != null) {
-                obj = u.unmarshal(data, c);
+                obj = JAXBUtils.unmarshall(context, data, c).getValue();
             } else {
-                obj = u.unmarshal(data);
-            }
-            if (obj instanceof JAXBElement<?>) {
-                JAXBElement<?> el = (JAXBElement<?>)obj;
-                obj = el.getValue();
-
+                Object o = JAXBUtils.unmarshall(context, data);
+                if (o instanceof JAXBElement<?>) {
+                    JAXBElement<?> el = (JAXBElement<?>)o;
+                    @SuppressWarnings("unchecked")
+                    T ot = (T)el.getValue();
+                    obj = ot;
+                }                
             }
             return obj;
         } catch (JAXBException e) {
@@ -68,7 +67,6 @@ public final class JAXBBeanFactory {
             } catch (XMLStreamException ex) {
                 throw new RuntimeException(ex);
             }
-            JAXBUtils.closeUnmarshaller(u);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
index dec36de..d113d3b 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
@@ -441,6 +441,7 @@ public class VersionTransformer {
         }
         JAXBContext ctx = getExposedJAXBContext(tns);
         Unmarshaller um = ctx.createUnmarshaller();
+        um.setEventHandler(null);
         try {
             JAXBElement<?> o = um.unmarshal(ref, getExposedReferenceType(tns));
             if (o != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 274967f..662ca63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
     <properties>
         <cxf.compiler.fork>false</cxf.compiler.fork>
         <cxf.build-utils.version>3.1.0</cxf.build-utils.version>
-        <cxf.xjc-utils.version>3.0.3</cxf.xjc-utils.version>
+        <cxf.xjc-utils.version>3.0.4-SNAPSHOT</cxf.xjc-utils.version>
         <cxf.jdk.version>1.7</cxf.jdk.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <site.deploy.url>scp://people.apache.org/www/cxf.apache.org/maven-site</site.deploy.url>

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index 5910641..600810e 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -172,9 +172,15 @@
                         <id>generate-sources</id>
                         <phase>generate-sources</phase>
                         <configuration>
+                            <extensions>
+                                <extension>org.apache.cxf.xjcplugins:cxf-xjc-bug986:${cxf.xjc-utils.version}</extension>
+                            </extensions>
                             <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                             <xsdOptions>
                                 <xsdOption>
+                                    <extensionArgs>
+                                        <arg>-Xbug986</arg>
+                                    </extensionArgs>
                                     <xsd>${basedir}/src/main/resources/schemas/configuration/http-jetty.xsd</xsd>
                                     <catalog>${basedir}/src/main/build-resources/catalog.cat</catalog>
                                     <deleteDirs>

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
index 21ea18d..4b49d83 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
@@ -30,11 +30,11 @@ import java.util.logging.Logger;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 
 import org.w3c.dom.Element;
 
 import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.common.jaxb.JAXBUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -228,12 +228,10 @@ public class JettyHTTPServerEngineFactoryHolder {
         this.handlersMap = handlersMap;
     }
 
-    protected Object getJaxbObject(Element parent, Class<?> c) {
+    protected <T> T getJaxbObject(Element parent, Class<T> c) {
 
         try {
-            Unmarshaller umr = getContext(c).createUnmarshaller();
-            JAXBElement<?> ele = (JAXBElement<?>) umr.unmarshal(parent);
-
+            JAXBElement<T> ele = JAXBUtils.unmarshall(getContext(c), parent, c);
             return ele.getValue();
         } catch (JAXBException e) {
             LOG.warning("Unable to parse property due to " + e);

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
----------------------------------------------------------------------
diff --git a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
index 75e20d4..a324593 100644
--- a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
+++ b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
@@ -493,6 +493,7 @@ public class MAPCodec extends AbstractSoapInterceptor {
                                     VersionTransformer.getExposedJAXBContext(headerURI);
                                 unmarshaller = 
                                     jaxbContext.createUnmarshaller();
+                                unmarshaller.setEventHandler(null);
                             }
                             if (maps == null) {
                                 maps = new AddressingProperties();

http://git-wip-us.apache.org/repos/asf/cxf/blob/81f0b461/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
----------------------------------------------------------------------
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
index 17966b4..c00c8b2 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
@@ -99,7 +99,9 @@ public class JaxbAssertionBuilder<T> implements AssertionBuilder<Element>
{
     
     protected Unmarshaller getUnmarshaller() {
         try {
-            return getContext().createUnmarshaller();
+            Unmarshaller um = getContext().createUnmarshaller();
+            um.setEventHandler(null);
+            return um;
         } catch (JAXBException e) {
             throw new RuntimeException(e);
         }


Mime
View raw message