[
https://issues.apache.org/jira/browse/CXF-4245?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Beryozkin updated CXF-4245:
----------------------------------
Component/s: (was: JAXB Databinding)
OtherDatabindings
Assignee: Sergey Beryozkin
> JAX-RS databinding support for JiBX
> -----------------------------------
>
> Key: CXF-4245
> URL: https://issues.apache.org/jira/browse/CXF-4245
> Project: CXF
> Issue Type: Bug
> Components: OtherDatabindings
> Affects Versions: 2.6
> Environment: All Environments
> Reporter: Don Corley
> Assignee: Sergey Beryozkin
> Labels: JiBX, databinding, jax-rs
> Fix For: 2.6.1, 2.5.4
>
>
> Dan,
> Thanks again for writing the databinding components for JiBX.
> Unfortunately, the JAX-RS component calls empty methods when I try to use
> this databinding component.
> This seems to fix the problem:
> ---start patch
> Index:
> rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
> ===================================================================
> --- rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
> (revision 1327050)
> +++ rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
> (working copy)
> @@ -40,6 +40,15 @@
> public class JibxDataWriter implements DataWriter<XMLStreamWriter> {
>
> public void write(Object obj, XMLStreamWriter output) {
> + try {
> + IBindingFactory factory =
> BindingDirectory.getFactory(obj.getClass());
> + IMarshallingContext ctx = getMarshallingContext(obj);
> + StAXWriter writer = new StAXWriter(factory.getNamespaces(),
> output);
> + ctx.setXmlWriter(writer);
> + ((IMarshallable)obj).marshal(ctx);
> + } catch (Exception e) {
> + throw new RuntimeException(e);
> + }
> }
>
> public void write(Object obj, MessagePartInfo part, XMLStreamWriter
> output) {
> Index:
> rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
> ===================================================================
> --- rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
> (revision 1327050)
> +++ rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
> (working copy)
> @@ -62,7 +62,12 @@
> }
>
> public Object read(QName elementQName, XMLStreamReader input, Class<?>
> type) {
> - throw new UnsupportedOperationException("Not Implemented");
> + try {
> + UnmarshallingContext ctx = getUnmarshallingContext(input, type);
> + return ctx.unmarshalElement(type);
> + } catch (JiBXException e) {
> + throw new RuntimeException(e);
> + }
> }
>
> public void setAttachments(Collection<Attachment> attachments) {
> --- end patch
> I have a sample project at if you want to see a working configuration:
> https://github.com/jibx/maven-plugin/tree/master/examples/cxf-jaxrs
> Remember to shutdown karaf after install, before start to avoid a karaf
> wiring bug.
> Thanks!
> Don
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira