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)

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


--

Back to the top