<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 Juan,<div><br></div><div>I have had this argument many times and to me it does not come down to “coupling” vs. “no coupling” but to “implicit coupling” vs. “explicit coupling”.</div><div><br></div><div>Even if you don’t use a shared interface (and, btw, you don’t have to share the interface in Errai) you still have coupling. In most cases, you can’t simply change the server-side REST endpoint without breaking existing clients and without changing your JavaScript code. The difference here is merely that in Errai it will fail at compile time while in other cases you will fail at runtime.</div><div><br></div><div>Cheers,</div><div>Christian</div><div><br><div><div>On Nov 19, 2014, at 11:15 AM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On 11/19/2014 04:58 PM, Martin Betak wrote:<br><blockquote type="cite">Hi all,<br><br>I've been exploring the possibilities of utilizing Errai JAX-RS for REST client in<span class="Apple-converted-space"> </span><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<span class="Apple-converted-space"> </span><br>and generate proxies automatically thus eliminating the need for extensive manual<br>code generation.<br><br></blockquote><br>I strongly discourage this approach, as it will couple the client and<br>the RESTAPI server implementation classes, similar coupling to what we<br>have today between the client and the backend entities and parameters<br>classes.<br><br>The contract of the RESTAPI is the XML schema that defines the entities<br>and the RSDL that defines resources and actions. Everything else is<br>subject to change and there is (and won't be) any backwards<br>compatibility commitment. The resource interfaces in particular are not<br>part of the contract, they are internal implementation details.<br><br>If you eventually decide to go this direction then you should create<br>your own resource interfaces.<br><br><blockquote type="cite">[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<span class="Apple-converted-space"> </span><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.<span class="Apple-converted-space"> </span><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> @XmlElement(name = "vm")<br> protected List<VM> 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>_______________________________________________<br>Devel mailing list<br><a href="mailto:Devel@ovirt.org">Devel@ovirt.org</a><br><a href="http://lists.ovirt.org/mailman/listinfo/devel">http://lists.ovirt.org/mailman/listinfo/devel</a><br><br></blockquote><br><br>--<span class="Apple-converted-space"> </span><br>Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>3ºD, 28016 Madrid, Spain<br>Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.</div></blockquote></div><br></div></body></html>