On Oct 6, 2009, at 10:19 AM, Paul Sandoz wrote:
> On Oct 5, 2009, at 7:23 PM, Jan Algermissen wrote:
>
>>
>> Given that HttpContext is a Jersey 'extension' - how would one
>> access the response object if not using the ResponseBuilder pattern?
>>
>> E.g. if I had
>>
>> public StreamingOutput getResource(
>> final @Context HttpContext hc, // Jersey
>> specific class
>> @PathParam("id") String id
>> ) {
>> return new StreamingOutput() {
>> public void write(OutputStream outputStream) {
>> Response resp = hc.getResponse();
>> // do something with response, e.g. set headers
>>
>> PrintWriter out = new PrintWriter(outputStream);
>> out.println("Foo");
>> out.close();
>> } };
>> }
>>
>>
>> How could I avoid the Jersey specific class?
>>
>
> It is currently not possible. If one needs to do that then a message
> body writer can be used. For example you could write your own
> version of StreamingOutput and your own message body writer that
> supports the setting of headers e.g.
>
> public MyStreamingOutput {
> write(MultivaluedMap headers, OutputStream out);
> }
>
Hmm, I think I don't get it - how would the MessageBodyWriter or the
e.g. getResource method ever get hold of the response object?
>
>> Thanks,
>>
>> Jan
>>
>> P.S. Is there actually a better list to use for these kinds of
>> questions? Seems so quiet over here...
>>
>
> What are you using to monitor the list?
Ah - sorry. Yes, I figured yesterday that I wasn't subscribed to the
list but only to users_at_jsr311xxx.
Thanks,
Jan
> (BTW the reason why i CC you is because you are not a member of the
> list so i CC just in case you are not monitoring by other means,
> also the list is moderated so i have to approve each email you send,
> which is why there might be the occasional delay).
>
> So far this month there have been 87 emails.
>
> See the archive:
>
> http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users
>
> Paul.
--------------------------------------
Jan Algermissen
Mail: algermissen_at_acm.org
Blog:
http://algermissen.blogspot.com/
Home:
http://www.jalgermissen.com
--------------------------------------