开发者

JAXB and class instantiation

开发者 https://www.devze.com 2023-04-05 15:04 出处:网络
One thing that prevents from using a binding technology like JAXB, instead of a classic dom/sax-based xml technology is the fact that, when reading xml, it seems to be strongly oriented to instantiate

One thing that prevents from using a binding technology like JAXB, instead of a classic dom/sax-based xml technology is the fact that, when reading xml, it seems to be strongly oriented to instantiate the classes that it manages.

Many times, i want to read values from xml and set them to properties of already created instances.

Is there a simple way to tell JAXB that it has to appl开发者_Python百科y values to the class that i have instead of create a new one?


Use the JAXB objects as DTOs. Then you can use PropertyUtils.copyProperties(..) / BeanUtils.copyProperties(..) (from commons-beanutils) to transfer the properties to your already-partially-populated objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号