You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andreas Benneke (JIRA)" <ji...@apache.org> on 2008/06/27 12:25:45 UTC
[jira] Created: (CXF-1674) JAXB unmarshalling cannot be configured
to use the ObjectFactory
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.0.7, 2.1.1
Reporter: Andreas Benneke
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.
[jira] Assigned: (CXF-1674) JAXB unmarshalling cannot be configured
to use the ObjectFactory
Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-1674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp reassigned CXF-1674:
--------------------------------
Assignee: Daniel Kulp
> 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
>
> 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.
[jira] Resolved: (CXF-1674) JAXB unmarshalling cannot be configured
to use the ObjectFactory
Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
[ 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.