axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Veithen (JIRA)" <>
Subject [jira] Commented: (AXIS2-4235) DefaultObjectSupplier cannot attach inner classes to the proper enclosing class instance
Date Sun, 26 Jul 2009 19:23:14 GMT


Andreas Veithen commented on AXIS2-4235:

For the compatibility issue, what we should do is:

- Define a new interface with a method like this:

Object getObject(ObjectSupplierContext context, Class clazz)

The new ObjectSupplierContext class would then have a getParentObject() method. Introducing
this additional class guarantees extensibility: we can pass other information simply by adding
new methods to ObjectSupplierContext, without breaking existing implementations.

- Create an adapter class so that internally we only use the new interface.

However, before accepting this change, I would like to see a sample use case for this (that
we could later add to the documentation). In fact, in the example given in the description
above, the reference from Inner to Parent is never used, so that one could argue that Inner
should be declared static anyway. Can you provide another example that clearly shows that
adding the requested feature is useful?

> DefaultObjectSupplier cannot attach inner classes to the proper enclosing class instance
> ----------------------------------------------------------------------------------------
>                 Key: AXIS2-4235
>                 URL:
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, kernel
>    Affects Versions: 1.5, 1.4.1, 1.4
>            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.

View raw message