<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>Just a quick follow-up on 2.)</div><div><br></div><div>As it happens, I just received a pull request for the first part of this (allow to plug in a simple custom JAX-RS marshaller). Yay, open source! ;)&nbsp;</div><div><br></div><div>You can track the progress here:</div><div><a href="https://issues.jboss.org/browse/ERRAI-796">https://issues.jboss.org/browse/ERRAI-796</a></div><div><br></div><div>This will allow you to rename fields using Jackson annotations.&nbsp;</div><div><br></div><div>Cheers,</div><div>Christian</div><div><br><div><div>On Nov 19, 2014, at 12:01 PM, Christian Sadilek &lt;<a href="mailto:csadilek@redhat.com">csadilek@redhat.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Martin,<div><br></div><div>Thanks for looking into this!<br><div><div><br></div><div>1) Yes, Errai supports client-side request interceptors that can be used to manipulate the request in any way you want (i.e. for caching or security purposes):&nbsp;<a href="http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-19398997_ErraiJAX-RS-ClientsideInterceptors">http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-19398997_ErraiJAX-RS-ClientsideInterceptors</a>. However, the content-type header should really be controlled (and is automatically set) based on the @Consumes annotation. Of course you can override it, if required.</div><div><br></div><div>2) By default, Errai comes with its own marshalling system and customized JSON format. It supports heterogenous collections, immutable types, back references and much more which required adding additional framework-specific information to the payload (i.e. type information, object ids, etc.). In Errai JAX-RS you can also use standard Jackson based JSON which all JAX-RS implementations support. Errai does support customer marshallers too (&nbsp;<a href="http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-5931328_Marshalling-CustomMarshallers">http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-5931328_Marshalling-CustomMarshallers</a>) but this feature is not aligned with our Jackson support. We can talk about this more but it looks like I’ll have to add a feature for you here if that’s a blocking requirement?</div><div><br></div><div>Cheers,</div><div>Christian</div><div><br></div><div><div><div>On Nov 19, 2014, at 10:58 AM, Martin Betak &lt;<a href="mailto:mbetak@redhat.com">mbetak@redhat.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi all,<br><br>I've been exploring the possibilities of utilizing Errai JAX-RS for REST client in <br>our current GWT-based frontend. This would be a complement to Vojtech's oVirt.js library<br>which is very native to javascript and utilizes dynamic discovery of resources and actions.<br><br>Errai JAX-RS would enable us to reuse our restapi definitions of resource interfaces and entities <br>and generate proxies automatically thus eliminating the need for extensive manual<br>code generation.<br><br>[errai jax-rs] <a href="https://docs.jboss.org/author/display/ERRAI/Errai+JAX-RS">https://docs.jboss.org/author/display/ERRAI/Errai+JAX-RS</a><br><br>Unfortunately in my quest I stumbled upon some issues I couldn't exactly google or solve <br>and I would like to ask Mark or Christian, whether the below is somehow possible with Errai:<br><br>1) Adding custom header to every request (some form of request interceptors)<br>You, see our api returns by default XML and we of course want to consume JSON.<br>Thus adding 'Content-Type: application/json' as well as other custom authentication headers<br>is necessary for our usage.<br><br>2) Using custom JSONProvider/ObjectMapper instead of the default Jackson one. <br>In our JSONProvider [1] we use custom ObjectMapper [2] mainly to map JAX-B annotations<br>to json. Without this for example errai generates marshaller for the VMs resource<br><br>public class VMs {<br> &nbsp;&nbsp;&nbsp;@XmlElement(name = "vm")<br> &nbsp;&nbsp;&nbsp;protected List&lt;VM&gt; vMs;<br>}<br><br>that expects json field called "vMs" instead of the JAX-B specification "vm" which is the actual<br>format returned from the API. There may be other differencies such as [3] so I think the best solution<br>would be if we could tell errai to use specific JSONProvider for generating the marshallers.<br><br>This are the issues that so far seem to be the most blocking ones, others may arise along the way.<br><br>Thank you for any help provided.<br><br>Best regards,<br><br>Martin<br><br>[1] <a href="https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/JSONProvider.java">https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/JSONProvider.java</a><br>[2] <a href="https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomObjectMapper.java">https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomObjectMapper.java</a><br>[3] <a href="https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomBeanFactory.java">https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomBeanFactory.java</a><br>[resource schema] <a href="https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd">https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd</a><br></blockquote></div><br></div></div></div></div></blockquote></div><br></div></body></html>