axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1371442 - in /axis/axis2/java/core/trunk: modules/json/src/org/apache/axis2/json/JSONUtil.java modules/json/test-repository/services/POJOService.aar/META-INF/services.xml src/site/xdoc/docs/json_support.xml
Date Thu, 09 Aug 2012 20:32:36 GMT
Author: veithen
Date: Thu Aug  9 20:32:35 2012
New Revision: 1371442

URL: http://svn.apache.org/viewvc?rev=1371442&view=rev
Log:
AXIS2-5158: Use Parameter#getValue() instead of Parameter#getParameterElement() to get the
XML for the xmlToJsonNamespaceMap parameter. This should ensure that the feature can be used
in a Synapse proxy.

Modified:
    axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java
    axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml
    axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml

Modified: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java?rev=1371442&r1=1371441&r2=1371442&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java Thu Aug
 9 20:32:35 2012
@@ -26,19 +26,22 @@ import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
 
 public final class JSONUtil {
     private JSONUtil() {}
     
     public static Map<String,String> getNS2JNSMap(AxisService service) {
         Map<String,String> ns2jnsMap = new HashMap<String,String>();
-        Parameter param = service.getParameter("xmlToJsonNamespaceMap");
-        if (param != null) {
-            for (Iterator it = param.getParameterElement().getChildrenWithName(new QName("mapping"));
it.hasNext(); ) {
-                OMElement mapping = (OMElement)it.next();
-                ns2jnsMap.put(mapping.getAttributeValue(new QName("xmlNamespace")),
-                              mapping.getAttributeValue(new QName("jsonNamespace")));
+        Object value = service.getParameterValue("xmlToJsonNamespaceMap");
+        if (value != null) {
+            if (value instanceof OMElement && ((OMElement)value).getLocalName().equals("mappings"))
{
+                for (Iterator it = ((OMElement)value).getChildrenWithName(new QName("mapping"));
it.hasNext(); ) {
+                    OMElement mapping = (OMElement)it.next();
+                    ns2jnsMap.put(mapping.getAttributeValue(new QName("xmlNamespace")),
+                                  mapping.getAttributeValue(new QName("jsonNamespace")));
+                }
+            } else {
+                throw new IllegalArgumentException("Expected <mappings> element");
             }
         } else {
             // If no namespace map is defined, use a default map compatible with earlier
Axis2 versions

Modified: axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml?rev=1371442&r1=1371441&r2=1371442&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml
(original)
+++ axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml
Thu Aug  9 20:32:35 2012
@@ -26,6 +26,8 @@
     </messageReceivers>
     <parameter name="ServiceClass">org.apache.axis2.json.POJOService</parameter>
     <parameter name="xmlToJsonNamespaceMap">
-        <mapping xmlNamespace="http://example.org" jsonNamespace=""/>
+        <mappings>
+            <mapping xmlNamespace="http://example.org" jsonNamespace=""/>
+        </mappings>
     </parameter>
 </service>
\ No newline at end of file

Modified: axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml?rev=1371442&r1=1371441&r2=1371442&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml (original)
+++ axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml Thu Aug  9 20:32:35 2012
@@ -186,8 +186,10 @@ HTTP/1.1</code>
 <service name="...">
     ...
     <parameter name="xmlToJsonNamespaceMap">
-        <mapping xmlNamespace="http://example.org/foo" jsonNamespace=""/>
-        <mapping xmlNamespace="http://example.org/bar" jsonNamespace="bar"/>
+        <mappings>
+            <mapping xmlNamespace="http://example.org/foo" jsonNamespace=""/>
+            <mapping xmlNamespace="http://example.org/bar" jsonNamespace="bar"/>
+        </mappings>
     </parameter>
     ...
 </service>
@@ -325,7 +327,9 @@ HTTP/1.1</code>
                         configuration:</p>
 <pre><![CDATA[
 <parameter name="xmlToJsonNamespaceMap">
-    <mapping xmlNamespace="http://quickstart.samples/xsd" jsonNamespace=""/>
+    <mappings>
+        <mapping xmlNamespace="http://quickstart.samples/xsd" jsonNamespace=""/>
+    </mappings>
 </parameter>
 ]]></pre>
                         <p>The <tt>services.xml</tt> file can be found
under



Mime
View raw message