users@jersey.java.net

Re: [Jersey] Jersey Client and Spring

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 17 Dec 2008 11:14:25 +0100

On Dec 17, 2008, at 6:58 AM, 邓涛 wrote:

> web.xml
> <listener>
> <listener-class>org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
>
> <servlet>
> <servlet-name>rest-servlet</servlet-name>
> <servlet-class>
> com.sun.jersey.spi.spring.container.servlet.SpringServlet
> </servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>rest-servlet</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>

The above is for Spring integration with the server-side components
and not for configuration of the client.

Andrew, i think we may need to work on this to support Spring-based
configuration of WebResource instances. But am no Spring expert so
require some help working out an appropriate solution.

There is a method when creating a client to pass in the
IoCComponentProviderFactory to utilize. For example one could do:

  SpringComponentProviderFactory scpf = ...
  Client c = Client.create(new DefaultClientConfig(), scpf);

which means provider components like the message body readers/writers
can depend on Spring.

But currently a WebResource instance is created directly by the Client:

     public WebResource resource(URI u) {
         return new WebResource(this, u);
     }

How could we defer to Spring to instantiate and configure such an
instance? or specifically defer to the IoCComponentProviderFactory?

I think some code/config examples of what you want things to look like
would help me and others.

Paul.


>
>
> On Wed, Dec 17, 2008 at 2:57 AM, Andrew Ochsner
> <aochsner_at_cs.stanford.edu> wrote:
>> Hi all:
>>
>> Hoping this is easy, but is there any easy, straighforward way to
>> configure
>> a Client or a WebResource via Spring? I see references to IOC
>> support, but
>> it's not clear to me if there is a path. I want to configure the
>> endpoints
>> in Spring xml and have the class that wants to make REST calls be
>> rather
>> ignorant.
>>
>> Thoughts?
>>
>> Thanks
>> Andy O
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>