[ https://issues.apache.org/jira/browse/CXF-1674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp resolved CXF-1674. ------------------------------ Resolution: Fixed Fix Version/s: 2.1.2 > JAXB unmarshalling cannot be configured to use the ObjectFactory > ---------------------------------------------------------------- > > Key: CXF-1674 > URL: https://issues.apache.org/jira/browse/CXF-1674 > Project: CXF > Issue Type: Bug > Affects Versions: 2.1.1, 2.0.7 > Reporter: Andreas Benneke > Assignee: Daniel Kulp > Fix For: 2.1.2 > > > JAXB requires to explicitly configure the Unmarshaller to use the > ObjectFactory using setProperty - it will otherwise use reflection > (newInstance). An example: > package test; > @XmlRootElement > @XmlType(name = "data") > public class Data { > } > public class ExtendedData extends Data { > } > @XmlRegistry > public class ObjectFactory { > public Data createData() { > return new ExtendedData(); > } > } > public class Test { > public static void main(String[] args) throws Exception { > JAXBContext context = > JAXBContext.newInstance(Test.class.getPackage().getName()); > Unmarshaller u1 = context.createUnmarshaller(); > String xml = "<?xml version=\"1.0\"?><data/>"; > System.out.println(u1.unmarshal(new > StringReader(xml)).getClass().getName()); > Unmarshaller u2 = context.createUnmarshaller(); > > u2.setProperty(com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.FACTORY, > new ObjectFactory()); > System.out.println(u2.unmarshal(new > StringReader(xml)).getClass().getName()); > } > } > Output: > test.Data > test.ExtendedData > To allow setting the above property JAXBDataBinding, JAXBEncoderDecoder and > DataReaderImpl would require "unmarshallerProperties" (in line with existing > marshallerProperties for the DataWriterImpl). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.