Hi,
After my previous post with suggestion from Dennis, I have re-evaluate
the structure of both domain object and XML with other application
requirements. It is confirm the the domain object has to remain
unchanged. However, the XML structure can be changed.
So the same object model:
class Person {
private Set<EquipmentLineItem> lineItems;
}
class EquipmentLineItem {
private Equipment equipment;
private int quantity;
}
abstract class Equipment {
private String name;
}
class Phone extends Equipment {
private int someOtherAttrib;
}
class Pda extends Equipment {
private String someOtherAttrib;
}
Now, the XML will be look like what Dennis suggested in his reply to my
previous post:
<equipment>
<item>
<phone>Siemens S45</phone>
<quantity>5</quantity>
</item>
<item>
<pda>O2 XDA</pda>
<quantity>2</quantity>
</item>
</equipment>
Point to note is that, the binding will not construct Equipment subclass
itself this time. As you can see from the class declaration, there are
some other attributes specific to each subclass. So I would like to
delegate the instantiation of Equipment subclass to a factory method
instead. The factory method returns correct instance (fully initialized)
based on String between <phone> tag or <pda> tag (i.e. Siemens S45, O2 XDA)
public static Equipment getEquipment(String equipmentName)
Based on the above requirements, I am having 2 issues regarding binding:
1. How can I define the mapping for equipment so that different subclass
map to different element name?
2. I don't seems to make use of factory attribute correctly. While it
use the factory method to create new instance, it still override values
of the instance with one from the XML, which I do not want.
Could you give me a binding example for the situation? I am kind of
stuck now. Thank you very much, I know that the question is not a short one.
Regards,
Vairoj
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users