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.
[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...
[2]
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules...
[3]
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules...
[resource schema]
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules...