users@jersey.java.net

Re: [Jersey] is there a way to get hold of the resource bean from inside a MessageBodyWriter? (and Lift templates are kinda working...)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 15 May 2009 10:56:07 +0200

Hi James,

I just re-read your email and the requirements are a little different
that i originally thought, namely you want the last matching instance
of the resource class for a number of different scenarios.

You can inject UriInfo and call:

   UriInfo.getMatchedResources()

the first item in the returned list will be the last matching resource
class instance i.e. the one that returned a response. But be carefuly
in some cases there will be no matching resources, for example if an
exception mapper gets invoked e.g. because a filter throws an
exception and the mapper creates a response with a Node instance.

Paul.


On May 14, 2009, at 9:56 AM, James Strachan wrote:

> I can get hold of the body (the return value of the resource method)
> from the MessageBodyWriter interface and I can get the
> request/response/context/servletcontext injected - I'm just wondering
> if there's a clever way of getting the resource bean itself?
>
> The background to this is I've just about got Lift templates to work
> with Jersey (yay!) - using implicit views or having a Scala resource
> method return a template instance
> http://github.com/jstrachan/liftweb/tree/master/lift-jersey
>
> (currently the code depends on master of liftweb and might need a few
> more lift tweaks to be complete, so I'm thinking for now the code
> might be best inside the lift project itself)
>
> I'd like to expose the resource bean so it can be used by lift
> snippets in a canonical way, whether via the LiftTemplateProcessor or
> via the NodeWriter...
> http://github.com/jstrachan/liftweb/tree/master/lift-jersey/src/main/scala/net/liftweb/jersey/test/
>
> but wasn't sure yet how to find it from inside NodeWriter - anyone
> any ideas?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>