Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4245

JAX-RS databinding support for JiBX

    XMLWordPrintableJSON

    Details

    • Estimated Complexity:
      Unknown

      Description

      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

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              doncorley Don Corley
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: