Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] Thoughts on issue #546 (Allow to use @Produces and @Consumes at the Application class)

Santiago, do you have any information about expected times for donation of spec texts or how will it even take place?

I read on Twitter Oracle wasn't going to donate the texts, so they will all have to be reworded. I don't know if that's accurate or where did it came from.

Just wondering about it since this issue specifically would need a spec text change.


Regards,

Guillermo González de Agüero

El jue., 5 abr. 2018 8:44, Ondrej Mihályi <ondrej.mihalyi@xxxxxxxxxxx> escribió:
Absolutely +1

Simplicity for developers is very important and this should be also easy to specify and implement.

Ondro

From: jaxrs-dev-bounces@xxxxxxxxxxx <jaxrs-dev-bounces@xxxxxxxxxxx> on behalf of Guillermo González de Agüero <z06.guillermo@xxxxxxxxx>
Sent: Thursday, April 5, 2018 7:50:09 AM
To: jaxrs developer discussions
Subject: Re: [jaxrs-dev] Thoughts on issue #546 (Allow to use @Produces and @Consumes at the Application class)
 
Hi,

Exactly, now it looks for the annotation at method level, and then fallbacks to an anotation at class level. This would fallback again to the annotation at the Application class.

When developers don't specify the available media types, JAX-RS defaults to all, which allows users to request any media type they want, even not available ones. At least on Jersey, requesting an unavailable media types leads to an error response indicating there's no available MessageBodyWriter for it. Providing an easy way for developers to globally set the used media types mitigates this without having to put the same two annotations on all resources.


Regards,

Guillermo González de Agüero

El jue., 5 abr. 2018 a las 6:08, Christian Kaltepoth (<christian@xxxxxxxxxxxx>) escribió:
Hi Guillermo,

thanks for bringing this up. So the idea would be to fall back to looking for @Produces / @Consumes on the application class if no corresponding annotation is found on the resource method or class? I basically like the idea. It seems to be a very useful fallback behavior.

Christian

Am Mi., 4. Apr. 2018 um 18:30 Uhr schrieb Guillermo González de Agüero <z06.guillermo@xxxxxxxxx>:
Hi folks,

I'd like to get your attention on an issue I originally created that I think would be easy to implement and reduce boilerplate: https://github.com/eclipse-ee4j/jaxrs-api/issues/546

3.5 @Consumes and @Produces "MAY be applied to a resource method, a resource class, or to an entity provider. [...] In the absence of either of these annotations, support for any media type (“*/*”) is assumed."

Most REST services only allow a specific set of  media types (tipically JSON and/or XML). People usually end up having to write the @Consumes("application/json") and  @Produces("application/json") on all resources. Annotation inheritance at class level (using a BaseResource class) is explicitly disabled: 3.6 "Note that inheritance ofclass or interface annotations is not supported."

Therefore I think it should be pretty easy and useful to support putting those annotations on the Application class to determine the default value.

PS: As a side note, if JAX-RS components were CDI beans, this could be easily acomplished by user code via a CDI extension, searching for the annotation on the Application class, and applying that same annotation at runtime to any resource bean not declaring anything more specific. Just one more point towards CDI integration :)


Regards,

Guillermo González de Agüero
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


--
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev

Back to the top