users@jersey.java.net

[Jersey] Re: Decorating response entities

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Sat, 30 Jul 2011 19:50:23 -0700

On Sat, Jul 30, 2011 at 7:33 PM, Stephane Bailliez <sbailliez_at_gmail.com> wrote:
> Hey Tatu (coincidentally, just posted to user_at_jackson )
> n Sat, Jul 30, 2011 at 6:45 PM, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:
>>
>> The way I have done this has been to just define generic wrapper like
>> abstract class Request<T> {
>>   public Map<String,Object> headers; // or getters/setters
>>   public long timestamp;
>>   public ServiceDefs service;
>>   public T data;
>> }
>>
>> and using generic type with proper payload type on method signature,
>> routing from there as necessary (calling method that handles generic
>> info).
>
> So I have been trying initially a somewhat similar technique (at least if I
> understand well what you mean)  where I wanted to make it reasonably
> transparent, so I created a class called 'ResponseWrapper' which has
> identical factory methods to Response and does the wrapping of the entity.
> Works ok, but forces people to use it instead of standard api and thought it
> was not that great. The beef of the technique would end up being something

Yeah in my case I don't try to make it transparent, as I am not
writing a framework for others.
This means that exposing envelope handling is ok, especially since
number of end points is quite small.
If you want this to be handled truly transparently this won't quite
work, understandably.

-+ Tatu +-