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 bu...@apache.org on 2003/03/03 12:48:57 UTC

DO NOT REPLY [Bug 17588] New: - Bean without own but inherit properties ignors order of elements (includes fix)

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17588>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17588

Bean without own but inherit properties ignors order of elements (includes fix)

           Summary: Bean without own but inherit properties ignors order of
                    elements (includes fix)
           Product: Axis
           Version: 1.1RC1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: Oliver.Adler@syracom.de


WSDL2Java generates from the following schema definition:

<xsd:complexType name="C">
	<xsd:complexContent>
		<xsd:extension base="abc:B"/>
	</xsd:complexContent>
</xsd:complexType>

a bean without own properties. All properties are inherit from the base type B.
This generates a typeDesc without fields.
At the start, axis generates for the TypeDesc the BeanPropertyDescriptor by 
calling BeanUtils.getPB.
Inside this method their is a call processPropertyDescriptors. This method 
reorders the properties using the typeDesc.
If the bean itself has no fields the following code fails (typeDesc.getFields() 
returns null)

org.apache.axis.utils.BeanUtils:
...
public static BeanPropertyDescriptor[] processPropertyDescriptors(
                  PropertyDescriptor[] rawPd, Class cls) {
...
// If typeDesc meta data exists, re-order according to the fields
            if (typeDesc != null &&
                    typeDesc.getFields() != null) {
                ArrayList ordered = new ArrayList();
                // Add the TypeDesc elements first
...

I would recommend the following change to respect superclass fields
..
            if (typeDesc != null &&
                    typeDesc.getFields(true) != null) {
                ArrayList ordered = new ArrayList();
                // Add the TypeDesc elements first
...
This leads to another change in org.apache.axis.description.TypeDesc,to enable 
the method to handle a 
field variable with a null value.
public FieldDesc[] getFields(boolean searchParents) {
        if (searchParents) {
            // check superclasses if they exist
            Class cls = javaClass.getSuperclass();
            if (cls != null && !cls.getName().startsWith("java.")) {
                TypeDesc superDesc = getTypeDescForClass(cls);
                if (superDesc != null) {
                    FieldDesc [] parentFields = superDesc.getFields(true);
                    /*
                     * Oliver Adler
                     * CHANGE: in order to handle beans without own but inherit 
fields
                     * where fields is null
                     */
                    int sizeFields = 0;
                    if(fields != null)
                    {
                    	sizeFields = fields.length;
                    }
                    
                    FieldDesc [] ret = new FieldDesc[parentFields.length + 
sizeFields];
                    System.arraycopy(parentFields, 0, ret, 0, 
parentFields.length);
                    
                    if(fields != null)
                    {
                    	System.arraycopy(fields, 0, ret, parentFields.length, 
fields.length);
                    }
                    fields = ret;
                }
            }
        }

        return fields;
    }