You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2004/12/02 19:07:14 UTC

cvs commit: ws-axis/java/src/org/apache/axis/encoding SerializationContext.java

gawor       2004/12/02 10:07:14

  Modified:    java/src/org/apache/axis/encoding SerializationContext.java
  Log:
  changed slightly the order of how serializers are discovered. the class lookup for serializer is now done after the type mapping lookup and before class interface lookup. before this change the class lookup was done only at the very end as a last resort if no serializer was found. that led to problems where sometimes a subclass serializer was used to serialize the object even though a specific serializer was associated with the class (in metadata)
  
  Revision  Changes    Path
  1.100     +18 -28    ws-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- SerializationContext.java	1 Dec 2004 23:16:22 -0000	1.99
  +++ SerializationContext.java	2 Dec 2004 18:07:14 -0000	1.100
  @@ -1355,27 +1355,6 @@
                   ser.serialize(elemQName, attributes, value, this);
                   return;
               }
  -
  -            // if no serializer was configured try to find one dynamically using WSDLJava
  -            // generated metadata
  -            Class cls = value.getClass();
  -            Serializer serializer = getSerializerFromClass(cls, elemQName);
  -            if (serializer != null) {
  -                TypeDesc typedesc = TypeDesc.getTypeDescForClass(value.getClass());
  -                if (typedesc != null) {
  -                    QName qname = typedesc.getXmlType();
  -		    // Send the xmlType if indicated or if
  -		    // the actual xmlType is different than the
  -		    // prefered xmlType
  -                    if (shouldSendType ||
  -		        (xmlType != null && qname != null &&
  -			 (!xmlType.equals(qname)))) {
  -                        writeXMLType = qname;
  -                    }
  -                }
  -                serializer.serialize(elemQName, attributes, value, this);
  -                return;
  -            }
               throw new IOException(Messages.getMessage("noSerializer00",
                       value.getClass().getName(), "" + tm));
           }
  @@ -1453,17 +1432,31 @@
           }
   
           while (javaType != null) {
  +            // check type mapping
               serFactory = (SerializerFactory) tm.getSerializer(javaType, xmlType);
  -            if (serFactory != null)
  +            if (serFactory != null) {
                   break;
  +            }
  +
  +            // check the class for serializer
  +            Serializer serializer = getSerializerFromClass(javaType, xmlType);
  +            if (serializer != null) {
  +                if (actualXMLType != null) {
  +                    TypeDesc typedesc = TypeDesc.getTypeDescForClass(javaType);
  +                    if (typedesc != null) {
  +                        actualXMLType.value = typedesc.getXmlType();
  +                    }
  +                }
  +                return serializer;
  +            }
   
               // Walk my interfaces...
               serFactory = getSerializerFactoryFromInterface(javaType, xmlType, tm);
  -
  -            // Finally, head to my superclass
  -            if (serFactory != null)
  +            if (serFactory != null) {
                   break;
  +            }
   
  +            // Finally, head to my superclass
               javaType = javaType.getSuperclass();
           }
   
  @@ -1498,9 +1491,6 @@
       public String getValueAsString(Object value, QName xmlType) throws IOException {
           Class cls = value.getClass();
           Serializer ser = getSerializer(cls, xmlType, null);
  -        if (ser == null) {
  -            ser = getSerializerFromClass(cls, xmlType);
  -        }
           if (!(ser instanceof SimpleValueSerializer)) {
               throw new IOException(
                       Messages.getMessage("needSimpleValueSer",