--Apple-Mail=_11D9AD45-ABED-44D4-B52D-0964DA7A69AC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=windows-1252
Hi Martin,
Thanks for looking into this!
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): =
http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-1=
9398997_ErraiJAX-RS-ClientsideInterceptors. 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.
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 ( =
http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html_single/#sid-5=
931328_Marshalling-CustomMarshallers) but this feature is not aligned =
with our Jackson support. We can talk about this more but it looks like =
I=92ll have to add a feature for you here if that=92s a blocking =
requirement?
Cheers,
Christian
On Nov 19, 2014, at 10:58 AM, Martin Betak <mbetak(a)redhat.com> wrote:
Hi all,
=20
I've been exploring the possibilities of utilizing Errai JAX-RS for =
REST
client in=20
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.
=20
Errai JAX-RS would enable us to reuse our restapi definitions of =
resource
interfaces and entities=20
and generate proxies automatically thus eliminating the need for =
extensive manual
code generation.
=20
[errai jax-rs] =
https://docs.jboss.org/author/display/ERRAI/Errai+JAX-RS
=20
Unfortunately in my quest I stumbled upon some issues I couldn't =
exactly
google or solve=20
and I would like to ask Mark or Christian, whether the below is =
somehow possible with Errai:
=20
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.
=20
2) Using custom JSONProvider/ObjectMapper instead of the default =
Jackson one.=20
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
=20
public class VMs {
@XmlElement(name =3D "vm")
protected List<VM> vMs;
}
=20
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.
=20
This are the issues that so far seem to be the most blocking ones, =
others may
arise along the way.
=20
Thank you for any help provided.
=20
Best regards,
=20
Martin
=20
[1] =
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/=
restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/JSONP=
rovider.java
[2] =
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/=
restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/Custo=
mObjectMapper.java
[3] =
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/=
restapi/interface/definition/src/main/java/org/ovirt/engine/api/json/Custo=
mBeanFactory.java
[resource schema] =
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/=
restapi/interface/definition/src/main/resources/api.xsd
--Apple-Mail=_11D9AD45-ABED-44D4-B52D-0964DA7A69AC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=windows-1252
<html><head><meta http-equiv=3D"Content-Type"
content=3D"text/html =
charset=3Dwindows-1252"></head><body style=3D"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): <a =
href=3D"http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html...
e/#sid-19398997_ErraiJAX-RS-ClientsideInterceptors">http://docs.j...
errai/3.0.3.Final/errai/reference/html_single/#sid-19398997_ErraiJAX-RS-Cl=
ientsideInterceptors</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 =
( <a =
href=3D"http://docs.jboss.org/errai/3.0.3.Final/errai/reference/html...
e/#sid-5931328_Marshalling-CustomMarshallers">http://docs.jboss.o...
3.0.3.Final/errai/reference/html_single/#sid-5931328_Marshalling-CustomMar=
shallers</a>) but this feature is not aligned with our Jackson support. =
We can talk about this more but it looks like I=92ll have to add a =
feature for you here if that=92s a blocking =
requirement?</div><div><br></div><div>Cheers,</div><div>Christian</div><di=
v><br></div><div><div><div>On Nov 19, 2014, at 10:58 AM,
Martin Betak =
<<a
href=3D"mailto:mbetak@redhat.com">mbetak@redhat.com</a>> =
wrote:</div><br class=3D"Apple-interchange-newline"><blockquote
=
type=3D"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=3D"https://docs.jboss.org/author/display/ERRAI/Errai+JAX-RS&quo...
docs.jboss.org/author/display/ERRAI/Errai+JAX-RS</a><br><b...
=
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> =
@XmlElement(name =3D "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=3D"https://github.com/oVirt/ovirt-engine/blob/master/backend/ma...
modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/js=
on/JSONProvider.java">https://github.com/oVirt/ovirt-engine/blob/...
ckend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt=
/engine/api/json/JSONProvider.java</a><br>[2] <a =
href=3D"https://github.com/oVirt/ovirt-engine/blob/master/backend/ma...
modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/js=
on/CustomObjectMapper.java">https://github.com/oVirt/ovirt-engine...
ter/backend/manager/modules/restapi/interface/definition/src/main/java/org=
/ovirt/engine/api/json/CustomObjectMapper.java</a><br>[3] <a =
href=3D"https://github.com/oVirt/ovirt-engine/blob/master/backend/ma...
modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/js=
on/CustomBeanFactory.java">https://github.com/oVirt/ovirt-engine/...
er/backend/manager/modules/restapi/interface/definition/src/main/java/org/=
ovirt/engine/api/json/CustomBeanFactory.java</a><br>[resource schema] <a =
href=3D"https://github.com/oVirt/ovirt-engine/blob/master/backend/ma...
modules/restapi/interface/definition/src/main/resources/api.xsd">https://g=
ithub.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/i=
nterface/definition/src/main/resources/api.xsd</a><br></blockquote></div><=
br></div></div></div></body></html>=
--Apple-Mail=_11D9AD45-ABED-44D4-B52D-0964DA7A69AC--