DefaultObjectSupplier cannot attach inner classes to the proper enclosing class 
instance
----------------------------------------------------------------------------------------

                 Key: AXIS2-4235
                 URL: https://issues.apache.org/jira/browse/AXIS2-4235
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: adb, kernel
    Affects Versions: 1.4, 1.4.1, 1.5
            Reporter: Detelin Yordanov


Тhe default implementation of the ObjectSupplier interface is not capable of 
creating inner classes and attaching them to an already created parent 
instance. For example, suppose we have the following class hierarchy:

class Parent {
  String name;

  get/setName() { .. }
 
  class Inner {
      String innerName;
   }
}

Transformed into XML, thiis should look sth. like:

<Parent>
   <name>ParentName</name>
   <Inner>
       <innerName>InnerName</innerName>
   </Inner>
</Parent>

When ADB is parsing this, it will first invoke the ObjectSupplier requesting an 
instance of Parent.class, the created instance will be populated, setting its
name to "ParentName".
Then, ADB will proceed to create the Inner class instance, however now it will 
not use the already created Parent, but will create a new one (see 
DefaultObjectSupplier#getObject(..)). Thus the Inner class instance will have 
an internal reference to a newly initialized Parent instance, rather than to 
the already initialized and populated Parent instance. This means that the 
Inner class will see the Parent's name field as null, instead as "ParentName".

A possible, but not backward compatible solution would be to extend the 
ObjectSupplier interface (or create a new interface) adding a new method:

public Object getObject(Object parentObj, Class clazz)

The method should use the provided parentObj instance if the given "clazz" is 
an inner class and "parentObj" is an instance of its enclosing class.

The other change would be to modify the ADB BeanUtil and pass the corresponding 
parent instance on each call to the ObjectSupplier.

If this solution is acceptable, I could provide a patch.

Regards,
   Detelin
   

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to