Hello,
Sorry if this is a known issue that is already intended to be addressed
in
an upcoming release. From my reading of the mailing list, it is unclear
to
me whether that is the case. So I wanted to report this just in case.
It looks like there's a problem when you try to define multiple mappings
with abstract="true".
For example, given this binding:
<binding value-style="attribute">
<mapping name="sample" class="Sample">
<structure field="varA"/>
</mapping>
<mapping class="AnInterface" abstract="true"/>
<mapping name="one" class="AnInterfaceImpl"
extends="AnInterface">
<value name="foo" field="foo"/>
<structure field="anotherInterface"/>
</mapping>
<mapping class="AnotherInterface" abstract="true"/>
<mapping name="two" class="AnotherInterfaceImpl"
extends="AnotherInterface">
<value name="bar" field="bar"/>
</mapping>
</binding>
where AnInterface and AnotherInterface are just marker interfaces
containing
no methods, the implementations of these interfaces look like:
public class AnInterfaceImpl implements AnInterface {
private String foo;
private AnotherInterface anotherInterface;
}
public class AnotherInterfaceImpl implements AnotherInterface {
private String bar;
}
and Sample looks like:
public class Sample {
private AnInterface varA;
}
when I try to unmarshal a document such as:
<sample>
<one foo="aaaa">
<two bar="xxxx"/>
</one>
</sample>
I get a JiBX exception with the message:
Element "one" has no mapping that extends AnotherInterface
I get a similar exception if I define the "type" attribute of the
"structure"
mappings in the binding above.
Element "two" has no mapping that extends AnInterface
To work around this, I have to not define the abstract mapping for
AnotherInterface __and__ adjust the mapping for AnInterfaceImpl to:
<mapping name="one" class="AnInterfaceImpl" extends="AnInterface">
<value name="foo" field="foo"/>
<!-- use a collection with structure subelements for each
implementation of AnotherInterface-->
<collection add-method="add" iter-method="iterator">
<structure type="AnotherInterfaceImpl"/>
</collection>
</mapping>
which is unfortunate since I don't want a collection of
AnotherInterfaceImpl, I just want one instance and I have many
implementations of AnotherInterface
Is there a better workaround for this issue? Or a correct way to define
the
bindings?
Thanks,
David
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users