If this were a GET request, I'd agree with Friso in questioning your need
for a polymorphic response. But since you're returning the result of a POST
operation, this should be a more reasonable, assuming A & B are also in the
same class hierarchy. If the two response types are completely disjoint,
then I'd question your approach.

And as Friso suggests, wrapping your objects in a Response is the right way
to go. Typically I've found making all resource methods return a Response
object offers a lot more flexibility, especially when you want to control
headers or handle error conditions.


On Mon, Aug 19, 2013 at 9:43 AM, Friso Vrolijken <friso.vrolij...@caci.nl>wrote:

> Hi Jason,
> First I'd ask myself if I'd really want this. The basic idea behind REST
> is that you address a resource, for which you might have several
> representations. Does not sound like you're doing that.
> If you find that you indeed need to do that, I suppose the easiest
> solution would be to have your method return a Response.
> Something like:
>   return Response.ok(A).build();
> or:
>   return Response.ok(Bs).build();
> Would do the trick, assuming that A and B have known representations.
> Groeten,
> Friso
> -----Oorspronkelijk bericht-----
> Van: Jason Novotny [mailto:jason.novo...@gmail.com]
> Verzonden: woensdag 14 augustus 2013 10:52
> Aan: resteasy-users@lists.sourceforge.net
> Onderwerp: [Resteasy-users] handling polymorphic rest request
> Hi,
>      I'm using RESTeasy with jackson and making a rest POST that either
> returns an object of type A or returns a list of objects of type B. How can
> I handle both of these cases? Do I need to override
> org.jboss.resteasy.client.core.BaseClientResponse? Any example would be
> much appreciated.
>      Thanks, Jason
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users

Ryan J. McDonough
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
Resteasy-users mailing list

Reply via email to