On Apr 21, 2010, at 5:29 PM, James Russo wrote:
>
> On Apr 21, 2010, at 11:18 AM, Paul Sandoz wrote:
>
>> Yes. Method parameters, for methods that Jersey invokes, are
>> independent of the scope of the class. Setter methods and fields
>> are not. But in this case Jersey will inject a thread local proxy
>> for HttpServletRequest so you can use it with singleton-scoped
>> classes.
>
> Understood. So, if I have a @Context HttpServletRequest as a class
> variable, the @Scope will need to be request based.
>
By class variable do you mean field of a class? then no. You can do
this:
@Component
@Scope("singleton")
public class MyBean {
@Context HttpServletRequest r; // thread local proxy is injected
@GET
public ... getIt(@Context HttpServletRequest r /* Independent of
class scope*/)
{ ... }
}
>> IIRC if your beans are managed by Spring then by default they are
>> singletons.
>
> They are. So, when you said it wasn't possible to not have a
> request, is it possible within the context of spring?
Does what i wrote above help clarify?
> When we aren't using the Jersey filter, but rather the
> com.sun.jersey.spi.spring.container.servlet.SpringServlet?
> Somehow I am getting null for request object.
>
AFAIK it shoild be possible to use SpringServlet as a filter or
servlet without issue.
Paul.