History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-393
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Joerg Schaible
Reporter: Jonatas Wingeter Rodrigues
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

XStream isn't consistent with Annotations.configureAliases method

Created: 23/Apr/07 09:59 AM   Updated: 25/Feb/08 05:01 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3

JDK version and platform: Sun 1.5.0_06 for linux


 Description  « Hide
We've a XML file with one root node (and some other attributes), and 2, 3 level nodes with a process of reading (xstream.fromXML).
a) The third level, before we change the business logic, it was a normal unique attribute. Configured the with Annotations.configureAliases(xstream, RootClassTest.class) was suficiently for the XStream find out all the other annotations in RootClassTest.class, and their HAS-A classes.
Therefore, all attributes from XML were mapped to RootClassTest and their children, by a single Annotations.configureAliases() invocation.

b) We changed the business logic and the 3 level attribute, named "objeto_postal", changed to List of "objeto_postal", thereby,
A implicit Collection was configured in the RootClassTest's child class to understand it as a collection.
The problem is that the system thrown a com.thoughtworks.xstream.mapper.CannotResolveClassException.

I understood that inserting a Annotations.configureAliases for each Annotated class related in XML, the problem is solved, but
some things are wrong, in contract terms:

1) If the configureAliases is needed for the unique RootClass node, all the annotated class, in relation HAS-A and HAS-MANY, should
be annotated automatic, not just HAS-A attributes. The main cause for this misunderstood is that configureAliases' javaDoc doesn't specify
the contract: "All annotated class must be configured". Even more I configured HAS-A classes annotated that ran without to use configureAliases.

2) If the configureAliases is needed for ALL topLevel nodes (when classes is annotated), so the framework doesn't cannot accept HAS-A annotated class not configured with.

If the XStream framework report a correct Exception (class annotated but not configured...No alias or annotation found for the element XXX in XML's reader process), it will be fine.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Jonatas Wingeter Rodrigues - 23/Apr/07 10:04 AM
The version is the latest XStream 1.2.1.

Guilherme Silveira - 02/May/07 02:51 PM
configureClass(type) now works as follows:

1. if the type has already/is currently being visited, skip
2. marks the type as visited
3. configures the type itself
4. for each field
4.1. if @XStreamContainedType is present, recursive call to the fields parameterized types
4.2. configure field level aliases
4.3. recursive call to the field type

The javadoc has been updated accordingly.

Joerg Schaible - 23/Nov/07 04:46 PM
The complete code has been refactored and your annotations should be detected now. You may give the head revision a try.

Joerg Schaible - 25/Feb/08 05:01 PM
Closing issues before next release.