Hi Juan,

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”.

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.

Cheers,
Christian

On Nov 19, 2014, at 11:15 AM, Juan Hernandez <jhern...@redhat.com> wrote:

> On 11/19/2014 04:58 PM, Martin Betak wrote:
>> Hi all,
>> 
>> I've been exploring the possibilities of utilizing Errai JAX-RS for REST 
>> client in 
>> our current GWT-based frontend. This would be a complement to Vojtech's 
>> oVirt.js library
>> which is very native to javascript and utilizes dynamic discovery of 
>> resources and actions.
>> 
>> Errai JAX-RS would enable us to reuse our restapi definitions of resource 
>> interfaces and entities 
>> and generate proxies automatically thus eliminating the need for extensive 
>> manual
>> code generation.
>> 
> 
> I strongly discourage this approach, as it will couple the client and
> the RESTAPI server implementation classes, similar coupling to what we
> have today between the client and the backend entities and parameters
> classes.
> 
> The contract of the RESTAPI is the XML schema that defines the entities
> and the RSDL that defines resources and actions. Everything else is
> subject to change and there is (and won't be) any backwards
> compatibility commitment. The resource interfaces in particular are not
> part of the contract, they are internal implementation details.
> 
> If you eventually decide to go this direction then you should create
> your own resource interfaces.
> 
>> [errai jax-rs] https://docs.jboss.org/author/display/ERRAI/Errai+JAX-RS
>> 
>> Unfortunately in my quest I stumbled upon some issues I couldn't exactly 
>> google or solve 
>> and I would like to ask Mark or Christian, whether the below is somehow 
>> possible with Errai:
>> 
>> 1) Adding custom header to every request (some form of request interceptors)
>> You, see our api returns by default XML and we of course want to consume 
>> JSON.
>> Thus adding 'Content-Type: application/json' as well as other custom 
>> authentication headers
>> is necessary for our usage.
>> 
>> 2) Using custom JSONProvider/ObjectMapper instead of the default Jackson 
>> one. 
>> In our JSONProvider [1] we use custom ObjectMapper [2] mainly to map JAX-B 
>> annotations
>> to json. Without this for example errai generates marshaller for the VMs 
>> resource
>> 
>> public class VMs {
>>    @XmlElement(name = "vm")
>>    protected List<VM> vMs;
>> }
>> 
>> that expects json field called "vMs" instead of the JAX-B specification "vm" 
>> which is the actual
>> format returned from the API. There may be other differencies such as [3] so 
>> I think the best solution
>> would be if we could tell errai to use specific JSONProvider for generating 
>> the marshallers.
>> 
>> This are the issues that so far seem to be the most blocking ones, others 
>> may arise along the way.
>> 
>> Thank you for any help provided.
>> 
>> Best regards,
>> 
>> Martin
>> 
>> [1] 
>> https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/JSONProvider.java
>> [2] 
>> https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomObjectMapper.java
>> [3] 
>> https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/CustomBeanFactory.java
>> [resource schema] 
>> https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
>> _______________________________________________
>> Devel mailing list
>> Devel@ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/devel
>> 
> 
> 
> -- 
> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
> 3ºD, 28016 Madrid, Spain
> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

_______________________________________________
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel

Reply via email to