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

Key: XSTR-406
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Joerg Schaible
Reporter: John Redford
Votes: 0
Watchers: 0
Operations

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

Provide reflection & annotation data to converter code

Created: 07/Jun/07 03:00 PM   Updated: 07/Jun/07 03:00 PM
Component/s: Converters, Core
Affects Version/s: 1.2.1
Fix Version/s: None


 Description  « Hide
While trying to implement a workaround to accomplish XSTR-405, I found no way for the code in a marshal method to access the annotations associated with the field/value that is being converted.

If this were possible, then it would be easy for developers to attach their own annotations and read them from the code that would convert a given class, without having to provide their own top-level converter.

It may seem like @XStreamConverter is an out here, but it offers no mechanism for providing per-use data values – and I don't think it could.

That is, you could not have (and would not want):

@XStreamConverter(class=MyClassConverter.class, customTweak=true)
MyClass fieldA;

@XStreamConverter(class=MyClassConverter.class, customTweak=false, tagName="foo")
MyClass fieldB;

But, if annotations were passed along, perhaps as part of the MarshallingContext, then I could write:

@XStreamConverter(MyClassConverter.class)
@MyAnno(customTweak=true)
MyClass fieldA;

@XStreamConverter(MyClassConverter.class)
@MyAnno(customTweak=true, tagName="foo")
MyClass fieldB;

It would also be very useful in the canConvert class to get access to this data. For compatibility, you could perhaps have:

interface ReflectiveConverter {
canConvert(Class clazz, AccessibleObject aobject);
}

and call that instead if the converter implements it.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.