cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1497726 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Date Fri, 28 Jun 2013 10:55:18 GMT
Author: sergeyb
Date: Fri Jun 28 10:55:18 2013
New Revision: 1497726

URL: http://svn.apache.org/r1497726
Log:
Merged revisions 1497725 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1497725 | sergeyb | 2013-06-28 11:52:47 +0100 (Fri, 28 Jun 2013) | 16 lines
  
  Merged revisions 1497715 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
  
  ................
    r1497715 | sergeyb | 2013-06-28 11:31:17 +0100 (Fri, 28 Jun 2013) | 9 lines
    
    Merged revisions 1497712 via svnmerge from 
    https://svn.apache.org/repos/asf/cxf/trunk
    
    ........
      r1497712 | sergeyb | 2013-06-28 11:17:23 +0100 (Fri, 28 Jun 2013) | 1 line
      
      [CXF-5100] Support for customizing namespace mapper and XML PI property names, take2
    ........
  ................
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1497715
  Merged /cxf/trunk:r1497712
  Merged /cxf/branches/2.6.x-fixes:r1497725

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1497726&r1=1497725&r2=1497726&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Fri Jun 28 10:55:18 2013
@@ -85,8 +85,8 @@ public abstract class AbstractJAXBProvid
     protected static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXBProvider.class);
 
     protected static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
-    protected static final String NS_MAPPER_PROPERTY = "com.sun.xml.bind.namespacePrefixMapper";
-    protected static final String NS_MAPPER_PROPERTY_INT = "com.sun.xml.internal.bind.namespacePrefixMapper";
+    protected static final String NS_MAPPER_PROPERTY_RI = "com.sun.xml.bind.namespacePrefixMapper";
+    protected static final String NS_MAPPER_PROPERTY_RI_INT = "com.sun.xml.internal.bind.namespacePrefixMapper";
     private static final String JAXB_DEFAULT_NAMESPACE = "##default";
     private static final String JAXB_DEFAULT_NAME = "##default";
     
@@ -127,10 +127,16 @@ public abstract class AbstractJAXBProvid
     private Unmarshaller.Listener unmarshallerListener;
     private Marshaller.Listener marshallerListener;
     private DocumentDepthProperties depthProperties;
+    private String namespaceMapperPropertyName;
     
-    protected static void setNamespaceMapper(Marshaller ms, Map<String, String> map)
throws Exception {
+    protected void setNamespaceMapper(Marshaller ms, 
+                                      Map<String, String> map) throws Exception {
         NamespaceMapper nsMapper = new NamespaceMapper(map);
-        setMarshallerProp(ms, nsMapper, NS_MAPPER_PROPERTY, NS_MAPPER_PROPERTY_INT);
+        if (namespaceMapperPropertyName != null) {
+            setMarshallerProp(ms, nsMapper, namespaceMapperPropertyName, null);
+        } else {
+            setMarshallerProp(ms, nsMapper, NS_MAPPER_PROPERTY_RI, NS_MAPPER_PROPERTY_RI_INT);
+        }
     }
     
     protected static void setMarshallerProp(Marshaller ms, Object value, 
@@ -138,7 +144,11 @@ public abstract class AbstractJAXBProvid
         try {
             ms.setProperty(name1, value);
         } catch (PropertyException ex) {
-            ms.setProperty(name2, value);
+            if (name2 != null) {
+                ms.setProperty(name2, value);
+            } else {
+                throw ex;
+            }
         }
         
     }
@@ -719,6 +729,10 @@ public abstract class AbstractJAXBProvid
         this.marshallerListener = marshallerListener;
     }
 
+    public void setNamespaceMapperPropertyName(String namespaceMapperProperty) {
+        this.namespaceMapperPropertyName = namespaceMapperProperty;
+    }
+
     @XmlRootElement
     protected static class CollectionWrapper {
         

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1497726&r1=1497725&r2=1497726&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Fri Jun 28 10:55:18 2013
@@ -76,8 +76,8 @@ import org.apache.cxf.staxutils.transfor
 @Provider
 public class JAXBElementProvider extends AbstractJAXBProvider  {
     private static final String XML_PI_START = "<?xml version=\"1.0\" encoding=\"";
-    private static final String XML_PI_PROPERTY = "com.sun.xml.bind.xmlHeaders";
-    private static final String XML_PI_PROPERTY_INT = "com.sun.xml.internal.bind.xmlHeaders";
+    private static final String XML_PI_PROPERTY_RI = "com.sun.xml.bind.xmlHeaders";
+    private static final String XML_PI_PROPERTY_RI_INT = "com.sun.xml.internal.bind.xmlHeaders";
     
     private static final List<String> MARSHALLER_PROPERTIES =
         Arrays.asList(new String[] {Marshaller.JAXB_ENCODING,
@@ -85,14 +85,15 @@ public class JAXBElementProvider extends
                                     Marshaller.JAXB_FRAGMENT,
                                     Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION,
                                     Marshaller.JAXB_SCHEMA_LOCATION,
-                                    NS_MAPPER_PROPERTY,
-                                    NS_MAPPER_PROPERTY_INT,
-                                    XML_PI_PROPERTY,
-                                    XML_PI_PROPERTY_INT});
+                                    NS_MAPPER_PROPERTY_RI,
+                                    NS_MAPPER_PROPERTY_RI_INT,
+                                    XML_PI_PROPERTY_RI,
+                                    XML_PI_PROPERTY_RI_INT});
     
     private Map<String, Object> mProperties = Collections.emptyMap();
     private Map<String, String> nsPrefixes = Collections.emptyMap();
     private String xmlResourceOffset = "";
+    private String xmlPiPropertyName;
     
     public JAXBElementProvider() {
         
@@ -106,6 +107,14 @@ public class JAXBElementProvider extends
         nsPrefixes = prefixes;
     }
     
+    protected void setXmlPiProperty(Marshaller ms, String value) throws Exception {
+        if (xmlPiPropertyName != null) {
+            setMarshallerProp(ms, value, xmlPiPropertyName, null);
+        } else {
+            setMarshallerProp(ms, value, XML_PI_PROPERTY_RI, XML_PI_PROPERTY_RI_INT);
+        }
+    }
+    
     @Override
     protected boolean canBeReadAsJaxbElement(Class<?> type) {
         return super.canBeReadAsJaxbElement(type) 
@@ -418,7 +427,7 @@ public class JAXBElementProvider extends
                 String absRef = buildAbsoluteXMLResourceURI(relRef);
                 value = value.substring(0, ind + 6) + absRef + "'?>";
             }
-            setMarshallerProp(ms, value, XML_PI_PROPERTY, XML_PI_PROPERTY_INT);
+            setXmlPiProperty(ms, value);
         }
     }
     
@@ -553,5 +562,9 @@ public class JAXBElementProvider extends
         throws Exception {
         ms.marshal(obj, writer);
     }
+
+    public void setXmlPiPropertyName(String xmlPiPropertyName) {
+        this.xmlPiPropertyName = xmlPiPropertyName;
+    }
     
 }



Mime
View raw message