You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ds...@apache.org on 2009/03/06 07:55:29 UTC

svn commit: r750787 - in /webservices/axis2/trunk/java/modules: jibx/src/org/apache/axis2/jibx/JiBXDataSource.java jibx/src/org/apache/axis2/jibx/NullBindingFactory.java jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl parent/pom.xml

Author: dsosnoski
Date: Fri Mar  6 06:55:29 2009
New Revision: 750787

URL: http://svn.apache.org/viewvc?rev=750787&view=rev
Log:
Update to JiBX 1.2 release

Modified:
    webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java
    webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/NullBindingFactory.java
    webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
    webservices/axis2/trunk/java/modules/parent/pom.xml

Modified: webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java?rev=750787&r1=750786&r2=750787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java Fri Mar  6 06:55:29 2009
@@ -41,28 +41,26 @@
 
 /** Data source for OM element backed by JiBX data bound object. */
 public class JiBXDataSource implements OMDataSource {
-    /**
-     * Marshaller index (only needed if object does not have a top-level mapping definition in the
-     * binding, <code>-1</code> if not used).
-     */
-    private final int marshallerIndex;
+    
+    /** Mapping name, for when abstract mapping is used directly; <code>null</code> if not used). */
+    private final String marshallerName;
 
-    /** Element name (only used with {@link #marshallerIndex}). */
+    /** Element name (only used with {@link #marshallerName}). */
     private final String elementName;
     
-    /** Element namespace URI (only used with {@link #marshallerIndex}). */
+    /** Element namespace URI (only used with {@link #marshallerName}). */
     private final String elementNamespace;
 
-    /** Element namespace prefix (only used with {@link #marshallerIndex}). */
+    /** Element namespace prefix (only used with {@link #marshallerName}). */
     private final String elementNamespacePrefix;
     
-    /** Element namespace index (only used with {@link #marshallerIndex}). */
+    /** Element namespace index (only used with {@link #marshallerName}). */
     private final int elementNamespaceIndex;
 
-    /** Indexes of namespaces to be opened (only used with {@link #marshallerIndex}). */
+    /** Indexes of namespaces to be opened (only used with {@link #marshallerName}). */
     private final int[] openNamespaceIndexes;
 
-    /** Prefixes of namespaces to be opened (only used with {@link #marshallerIndex}). */
+    /** Prefixes of namespaces to be opened (only used with {@link #marshallerName}). */
     private final String[] openNamespacePrefixes;
 
     /** Data object for output. */
@@ -78,7 +76,7 @@
      * @param factory
      */
     public JiBXDataSource(IMarshallable obj, IBindingFactory factory) {
-        marshallerIndex = -1;
+        marshallerName = null;
         dataObject = obj;
         bindingFactory = factory;
         elementName = elementNamespace = elementNamespacePrefix = null;
@@ -91,7 +89,7 @@
      * Constructor from object with mapping index and binding factory.
      *
      * @param obj
-     * @param index
+     * @param mapping
      * @param name
      * @param uri
      * @param prefix
@@ -99,13 +97,13 @@
      * @param nsprefixes
      * @param factory
      */
-    public JiBXDataSource(Object obj, int index, String name, String uri, String prefix,
+    public JiBXDataSource(Object obj, String mapping, String name, String uri, String prefix,
                           int[] nsindexes, String[] nsprefixes, IBindingFactory factory) {
-        if (index < 0) {
+        if (mapping == null) {
             throw new
-                    IllegalArgumentException("index value must be non-negative");
+                    IllegalArgumentException("mapping name must be supplied");
         }
-        marshallerIndex = index;
+        marshallerName = mapping;
         dataObject = obj;
         bindingFactory = factory;
         boolean found = false;
@@ -164,7 +162,7 @@
     private void marshal(boolean full, IMarshallingContext ctx) throws JiBXException {
         try {
             
-            if (marshallerIndex < 0) {
+            if (marshallerName == null) {
                 if (dataObject instanceof IMarshallable) {
                     ((IMarshallable)dataObject).marshal(ctx);
                 } else {
@@ -192,9 +190,7 @@
                 }
                 
                 // marshal object representation (may include attributes) into element
-                IMarshaller mrsh = ctx.getMarshaller(marshallerIndex,
-                                                     bindingFactory
-                                                             .getMappedClasses()[marshallerIndex]);
+                IMarshaller mrsh = ctx.getMarshaller(marshallerName);
                 mrsh.marshal(dataObject, ctx);
                 wrtr.endTag(nsidx, name);
             }
@@ -246,7 +242,7 @@
             // check if namespaces already declared for abstract mapping
             boolean full = true;
             String[] nss = bindingFactory.getNamespaces();
-            if (marshallerIndex >= 0) {
+            if (marshallerName != null) {
                 String prefix = xmlWriter.getPrefix(elementNamespace);
                 if (elementNamespacePrefix.equals(prefix)) {
                     full = false;

Modified: webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/NullBindingFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/NullBindingFactory.java?rev=750787&r1=750786&r2=750787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/NullBindingFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/NullBindingFactory.java Fri Mar  6 06:55:29 2009
@@ -20,24 +20,17 @@
 package org.apache.axis2.jibx;
 
 import org.jibx.runtime.IBindingFactory;
-import org.jibx.runtime.IMarshallingContext;
-import org.jibx.runtime.IUnmarshallingContext;
-import org.jibx.runtime.JiBXException;
-import org.jibx.runtime.impl.MarshallingContext;
-import org.jibx.runtime.impl.UnmarshallingContext;
+import org.jibx.runtime.impl.BindingFactoryBase;
 
-public class NullBindingFactory implements IBindingFactory {
-
-    private static final String[] EMPTY_STRINGS = new String[0];
-
-    public IMarshallingContext createMarshallingContext() throws JiBXException {
-        return new MarshallingContext(EMPTY_STRINGS, EMPTY_STRINGS, EMPTY_STRINGS, this);
-    }
-
-    public IUnmarshallingContext createUnmarshallingContext()
-            throws JiBXException {
-        return new UnmarshallingContext(0, EMPTY_STRINGS, EMPTY_STRINGS, EMPTY_STRINGS,
-                                        EMPTY_STRINGS, this);
+/**
+ * Dummy binding factory for when the generated Axis2 linkage code uses only simple value
+ * conversions (and hence doesn't need a real JiBX binding).
+ */
+public class NullBindingFactory extends BindingFactoryBase implements IBindingFactory {
+
+    public NullBindingFactory() {
+        super("", 0, 0, null, null, null, null, null, null, null, null, null, null, null, null,
+            null, null, null);
     }
 
     public String getCompilerDistribution() {
@@ -50,26 +43,6 @@
         return 0;
     }
 
-    public String[] getElementNames() {
-        return EMPTY_STRINGS;
-    }
-
-    public String[] getElementNamespaces() {
-        return EMPTY_STRINGS;
-    }
-
-    public String[] getMappedClasses() {
-        return EMPTY_STRINGS;
-    }
-
-    public String[] getNamespaces() {
-        return EMPTY_STRINGS;
-    }
-
-    public String[] getPrefixes() {
-        return EMPTY_STRINGS;
-    }
-
     public int getTypeIndex(String type) {
         return -1;
     }

Modified: webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl?rev=750787&r1=750786&r2=750787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl Fri Mar  6 06:55:29 2009
@@ -201,7 +201,7 @@
                           wrapper.addChild(mappedChild(result, factory));
               </xsl:when>
               <xsl:otherwise>
-                          org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_index<xsl:value-of select="out-wrapper/return-element/@type-index"/>, "<xsl:value-of select='out-wrapper/return-element/@name'/>", "<xsl:value-of select='out-wrapper/return-element/@ns'/>", "<xsl:value-of select='out-wrapper/return-element/@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
+                          org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_name<xsl:value-of select="out-wrapper/return-element/@type-index"/>, "<xsl:value-of select='out-wrapper/return-element/@name'/>", "<xsl:value-of select='out-wrapper/return-element/@ns'/>", "<xsl:value-of select='out-wrapper/return-element/@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
                           org.apache.axiom.om.OMNamespace appns = factory.createOMNamespace("<xsl:value-of select='out-wrapper/return-element/@ns'/>", "");
                           org.apache.axiom.om.OMElement child = factory.createOMElement(src, "<xsl:value-of select='out-wrapper/return-element/@name'/>", appns);
                           wrapper.addChild(child);
@@ -273,7 +273,7 @@
                   wrapper.addChild(mappedChild(result, factory));
               </xsl:when>
               <xsl:otherwise>
-                  org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_index<xsl:value-of select="out-wrapper/return-element/@type-index"/>, "<xsl:value-of select='out-wrapper/return-element/@name'/>", "<xsl:value-of select='out-wrapper/return-element/@ns'/>", "<xsl:value-of select='out-wrapper/return-element/@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
+                  org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(result, _type_name<xsl:value-of select="out-wrapper/return-element/@type-index"/>, "<xsl:value-of select='out-wrapper/return-element/@name'/>", "<xsl:value-of select='out-wrapper/return-element/@ns'/>", "<xsl:value-of select='out-wrapper/return-element/@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
                   org.apache.axiom.om.OMNamespace appns = factory.createOMNamespace("<xsl:value-of select='out-wrapper/return-element/@ns'/>", "");
                   org.apache.axiom.om.OMElement child = factory.createOMElement(src, "<xsl:value-of select='out-wrapper/return-element/@name'/>", appns);
                   wrapper.addChild(child);
@@ -634,7 +634,7 @@
         if (bindingFactory == null) {
             throw new RuntimeException(bindingErrorMessage);
         }
-        org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(<xsl:call-template name="parameter-or-array-item"/>, _type_index<xsl:value-of select="@type-index"/>, "<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "<xsl:value-of select='@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
+        org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(<xsl:call-template name="parameter-or-array-item"/>, _type_name<xsl:value-of select="@type-index"/>, "<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "<xsl:value-of select='@prefix'/>", bindingNamespaceIndexes, bindingNamespacePrefixes, bindingFactory);
         org.apache.axiom.om.OMNamespace appns = factory.createOMNamespace("<xsl:value-of select='@ns'/>", "");
         child = factory.createOMElement(src, "<xsl:value-of select='@name'/>", appns);
       </xsl:when>
@@ -834,7 +834,7 @@
     private org.apache.axiom.om.OMElement mappedChild(Object value, org.apache.axiom.om.OMFactory factory) {
         org.jibx.runtime.IMarshallable mrshable = (org.jibx.runtime.IMarshallable)value;
         org.apache.axiom.om.OMDataSource src = new org.apache.axis2.jibx.JiBXDataSource(mrshable, bindingFactory);
-        int index = mrshable.JiBX_getIndex();
+        int index = bindingFactory.getClassIndexMap().get(mrshable.JiBX_getName());
         org.apache.axiom.om.OMNamespace appns = factory.createOMNamespace(bindingFactory.getElementNamespaces()[index], "");
         return factory.createOMElement(src, bindingFactory.getElementNames()[index], appns);
     }
@@ -853,13 +853,13 @@
   
   <!-- Called by "initialize-binding" template to generate mapped class index fields. -->
   <xsl:template match="abstract-type" mode="generate-index-fields">
-          private static final int _type_index<xsl:value-of select="@type-index"/>;
+          private static final String _type_name<xsl:value-of select="@type-index"/>;
   </xsl:template>
     
   <!-- Called by "initialize-binding" template to initialize mapped class index fields. -->
   <xsl:template match="abstract-type" mode="set-index-fields">
-         _type_index<xsl:value-of select="@type-index"/> = (bindingFactory == null) ?
-            -1 : bindingFactory.getTypeIndex("{<xsl:value-of select="@ns"/>}:<xsl:value-of select="@name"/>");
+         _type_name<xsl:value-of select="@type-index"/> =
+             "{<xsl:value-of select="@ns"/>}:<xsl:value-of select="@name"/>";
   </xsl:template>
   
   
@@ -957,7 +957,7 @@
         uctx.unmarshalElement()
       </xsl:when>
       <xsl:when test="@form='complex'">
-        uctx.getUnmarshaller(_type_index<xsl:value-of select="@type-index"/>).unmarshal(<xsl:choose><xsl:when test="string-length(normalize-space(@create-type)) = 0">null</xsl:when><xsl:otherwise>new <xsl:value-of select="@create-type"/>()</xsl:otherwise></xsl:choose>, uctx)
+        uctx.getUnmarshaller(_type_name<xsl:value-of select="@type-index"/>).unmarshal(<xsl:choose><xsl:when test="string-length(normalize-space(@create-type)) = 0">null</xsl:when><xsl:otherwise>new <xsl:value-of select="@create-type"/>()</xsl:otherwise></xsl:choose>, uctx)
       </xsl:when>
     </xsl:choose>
   </xsl:template>

Modified: webservices/axis2/trunk/java/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/parent/pom.xml?rev=750787&r1=750786&r2=750787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/parent/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/parent/pom.xml Fri Mar  6 06:55:29 2009
@@ -116,7 +116,7 @@
         <jaxbri.version>2.1.7</jaxbri.version>
         <jaxen.version>1.1.1</jaxen.version>
         <jettison.version>1.0-RC2</jettison.version>
-        <jibx.version>1.1.5</jibx.version>
+        <jibx.version>1.2</jibx.version>
         <junit.version-jdk1.4>3.8.2</junit.version-jdk1.4>
         <junit.version>4.4</junit.version>
         <log4j.version>1.2.15</log4j.version>