cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6796) Improve or extend StringTextProvider to write an Object
Date Thu, 03 Mar 2016 09:59:18 GMT

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

Sergey Beryozkin commented on CXF-6796:
---------------------------------------

Hi Jim

Please create such a provider but I don't think it should be registered by default, what value
will it give CXF ? I'm not sure there's much value in having a custom bean's toString() being
returned, people want JSON, XML, but not custom toString() formats, whatever toStriing() of
Order/etc bean returns.

It can be more practically useful for passing primitive values (int, etc) or Enums around
as text/plain values, but it is so rare, services very rarely return "text/plain 2", etc.
Sot having such a provider (which can read and write) shipped with CXF can be useful in those
rare cases where it can be needed, but I'd not prefer having it registered by default as it
would only affect the cost of selecting the right provider in 95% cases.

Thanks


  

> Improve or extend StringTextProvider to write an Object 
> --------------------------------------------------------
>
>                 Key: CXF-6796
>                 URL: https://issues.apache.org/jira/browse/CXF-6796
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.1.5
>            Reporter: Jim Ma
>            Assignee: Sergey Beryozkin
>             Fix For: 3.1.6
>
>
> CXF reports it can't find the message writer for  OrderModel class and text/plain content
type when the resource class like the following:  
> {code}
> @Produces("text/plain")
> @Path("order/{id}")
> public class OrderResource {
>    @GET
>     public OrderModel get(@PathParam("id") @CustomMax int id) {
>         return new OrderModel(id);
>     }
> }
> {code}
> It is required to change the return Class to String and explicitly invoke toString()
return the String value
> {code}. 
> @Produces("text/plain")
> @Path("order/{id}")
> public class OrderResource {
>     @GET
>     public String get(@PathParam("id") @CustomMax int id) {
>         return new OrderModel(id).toString();
>     }
> }
> {code}
> We can improve StringTextProvider to write the Object with toString value to remove the
return type must be String class restriction.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message