You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (JIRA)" <ji...@apache.org> on 2017/06/11 19:44:18 UTC

[jira] [Comment Edited] (CXF-7403) [CDI] support overriding of consumes/produces for producers

    [ https://issues.apache.org/jira/browse/CXF-7403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046078#comment-16046078 ] 

Andriy Redko edited comment on CXF-7403 at 6/11/17 7:43 PM:
------------------------------------------------------------

Hi [~rmannibucau],

If there is a real use case, we can make this feature non-CDI specific, for example introducing extended version of @Consumes annotation, for example:
{code:java}
@Inherited
@Target({ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface Consumes {
    String[] value();
}
{code}

So we can use it like this in CDI context:

{code:java}
@Produces
public JacksonJsonProvider provider() {
    return new @Consumes(MediaType.APPLICATION_JSON) JacksonJsonProvider() {
    };
}
{code}

What do you think?  [~sergey_beryozkin] do you have opinion / idea about that?
Thanks.

Best Regards,
    Andriy Redko


was (Author: reta):
Hi [~rmannibucau],

If there is a real use case, we can make this feature non-CDI specific, for example introducing extended version of @Consumes annotation, for example:
{code:java}
@Inherited
@Target({ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface Consumes {
    String[] value();
}
{code:java}

So we can use it like this in CDI context:
{code:java}
@Produces
public JacksonJsonProvider provider() {
    return new @Consumes(MediaType.APPLICATION_JSON) JacksonJsonProvider() {
    };
}
{code:java}

What do you think?  [~sergey_beryozkin] do you have opinion / idea about that?
Thanks.

Best Regards,
    Andriy Redko

> [CDI] support overriding of consumes/produces for producers
> -----------------------------------------------------------
>
>                 Key: CXF-7403
>                 URL: https://issues.apache.org/jira/browse/CXF-7403
>             Project: CXF
>          Issue Type: New Feature
>            Reporter: Romain Manni-Bucau
>
> Idea is to be able to produce a @Provider (MessageBody[Reader|Writer) and override on the fly the @Consumes/@Produces of the class using the ones on the producer method (field? - in the annotated type of the producer).
> A sample would be:
> {code}
> javax...Produces
> @Produces("application/json")
> @Consumes("application/json")
> public JacksonProvider jsonProvider() {
>     return new JacksonProvider();
> }
> {code}
> This sample would allow to override in the application conflicting/broken media types (jackson uses wildcard by default leading to issues in JAX-RS 2 sorting when another provider uses application/*+json or so).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)