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

Key: XSTR-241
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Joerg Schaible
Reporter: Damon Rand
Votes: 0
Watchers: 1
Operations

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

Protected empty constructor should be valid for JavaBeanConverter

Created: 31/Aug/05 07:05 AM   Updated: 25/Feb/08 05:01 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3


 Description  « Hide
I spent quite some time trying and failing to get the JavaBeanConverter working until I realised that an empty constructor is required and needs to be public. Otherwise things default back to field based serialization. This is not ideal, my domain objects have empty protected constructors which work nicely with Hibernate getter/setter serialization for example.


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Damon Rand - 13/Sep/05 07:02 PM
I think JBC needs two changes to be as useful as field conversion.
- It would have to be able to deal with any visibility on both constructors and getters/setters.
- It would need some way of marking a visible get/set pair as "do not (de)serialize" -- the equivalent of the transient tag for field serialization.

Guilherme Silveira - 22/Mar/06 06:18 AM
Java 2 definition on javabeans oblies the public constructor with no args:
http://java.sun.com/developer/onlineTraining/Beans/JBeansAPI/shortcourse.html

Nevertheless its possible to create support for protected or any other no-args constructor, but that would make many objects a JavaBean even tough they are not, for example java.util.ArrayList would seem to be a javabean when it does not have the desired get/set standard that would allow it to be correctly converted. It would be impossible to foresee which classes with no-args constructors are javabeans and which one's aren't.

Joerg Schaible - 26/Jul/07 04:59 PM
The next release will allow you to use a JavaBeanConverter with a customized BeanProvider. Simply overwrite the getDefaultConstructor method and you may also return a protected one. However, it will be not implemented by default.

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