JAXB and class instantiation
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.
精彩评论