users@jersey.java.net

Re: Blog entry on my travails so far

From: ljnelson <ljnelson_at_gmail.com>
Date: Fri, 30 Apr 2010 08:44:40 -0700 (PDT)

On Fri, Apr 30, 2010 at 10:20 AM, Paul Sandoz [via Jersey]
<ml-node+4985892-1463926867-210534_at_n2.nabble.com> wrote:
> That is some hardcore JAXB usage!

Generally when I have to do something hardcore, it means I've done
something wrong. But when your resource classes return all sorts of
interfaces and generic types, well, I don't see a choice. :-P

I realized after putting the blog entry together that the coordination
space for the JAXB context resolver and the
MessageBodyWriter#writeTo() implementation doesn't have to be a
ThreadLocal. It could be a HttpServletRequest attribute! So my final
version actually injects the HttpServletRequest via @Context, and then
writeTo() sets the type information in there as a request attribute,
and the JAXBContextResolver pulls the type information from it. I
realize here I'm making an assumption about the ordering--namely that
writeTo happens before JAXB context resolution--but I think this is
probably an unspoken requirement of the specification.

Best,
Laird

-- 
View this message in context: http://jersey.576304.n2.nabble.com/Blog-entry-on-my-travails-so-far-tp4978821p4986373.html
Sent from the Jersey mailing list archive at Nabble.com.