users@jersey.java.net

Re: [Jersey] Spring request scoped bean plugged into Jersey Spring app

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 12 Jan 2010 14:47:28 +0100

Hi Ross,

So in your "Resource" you want to get access to another request Spring
bean?

Is your "Resource" a spring bean? if so you should be able to use
normal Spring-based injection to reference other Spring beans e.g.:

    @Path("/myresource")
    @Scope("request")
    public class MyResource {dsd
           @Autowired
      @Qualifier("1")
      private Other o;
    }

Note that you will need to add:

    <listener>
           <listener-class>org.springframework.web.context.request.RequestContextListener
</listener-class>
    </listener>
to the web.xml.

Perhaps it would help if you can send some example code of what you
want to achieve?

Paul.

On Jan 11, 2010, at 9:00 PM, Ross Mcdonald wrote:

> Hi Guys.
>
> Hoping someone can advise me how to do something, or an alternative
> approach.
>
> I have a pretty standard Jersey Spring app, using:
>
> com.sun.jersey.spi.spring.container.servlet.SpringServlet
>
> in my web.xml.
>
> I would like to take an HTTP header, retrieved in my Resource, and
> set the value of a variable in a request scoped spring bean, and
> then pull this from some spring services, also wired into my
> resource. This will cut out the need to pass parameters around.
>
> I am having trouble integrating Request scope capabilities in this
> way, can anyone point me to an easier alternative?
>
> Thanks for you help in advance,
>
> Ross
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>