Community
Participate
Working Groups
For Dynamic JAXB we need a way of specifying the class of collection being used, so that the underlying dynamic JavaModel can be built correctly. We currently have: <xml-element java-attribute="zipCodes" type="java.lang.Integer" xml-list="true"/> When xml-list is encountered, the JavaModel is asked if this property isArray(), but the only type information we have is Integer, and so an Integer property will be created (and therefore XMLProcessor will fail when processing this element). If we could have a way of hooking up a ContainerPolicy then the information would be available to the Dynamic JAXB boostrapping code. For example: <xml-element java-attribute="zipCodes" type="java.lang.Integer" collection-type="java.util.ArrayList"/> would allow us to generate ArrayList<Integer> zipCodes Other issues: - Would also need a way to specify that the Java attribute is an array (e.g. 'Integer[] zipCodes') - xml-list seems redundant if we were to add collection type information, should xml-list be assumed true in this case?
The design Wiki for this issue can be found here: http://wiki.eclipse.org/EclipseLink/DesignDocs/322284
xml-list should not be assumed in this case. Consider this: when a collection property is annotated with @XmlElement, each item in the collection will be wrapped by an element. For example, @XmlRootElement class Foo { @XmlElement List<String> data; } would produce XML like this: <foo> <data>abc</data> <data>def</data> </foo> @XmlList annotation, allows multiple values to be represented as whitespace-separated tokens in a single element. For example, @XmlRootElement class Foo { @XmlElement @XmlList List<String> data; } would produce XML like this: <foo> <data>abc def</data> </foo>
In JPA, an array type is declared using attribute-type as follows: attribute-type="java.lang.Integer[]" I propose we do the same thing, i.e. collection-type="java.lang.Integer[]"
Created attachment 179867 [details] Proposed fix.
Created attachment 179868 [details] Supporting test cases
Created attachment 179876 [details] Proposed fix.
Created attachment 179877 [details] Supporting test cases
Arrays will not be supported at this time. An enhancement request has been opened to track this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326548
reviewed by: matt.macivor@oracle.com tests: all unit tests pass as expected; jaxb/externalizedmetadata/xmlanyattribute/XmlAnyAttributeTestCases; jaxb/externalizedmetadata/xmlanyelement/XmlAnyElementTestCases; jaxb/externalizedmetadata/xmlattribute/XmlAttributeTestCases; jaxb/externalizedmetadata/xmlelement/XmlElementTestCases; jaxb/externalizedmetadata/xmlelement/XmlElementsTestCases; jaxb/externalizedmetadata/xmlelement/XmlValueTestCases
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink