cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Schoening <robschoen...@gmail.com>
Subject Re: WebClient & Spring
Date Wed, 06 Jan 2010 19:26:12 GMT
I am able to programmatically instantiate a Client using the following code:

Bus bus =  ctx.getBean("cxf",Bus.class);
JAXRSClientFactoryBean cfb= new JAXRSClientFactoryBean();
cfb.setBus(bus);
cfb.setAddress("http://www.yahoo.com");
WebClient wc = cfb.createWebClient();

However, the "problem" is that HTTPConduit returned by:

WebClient.getConfig(wc).getHttpConduit()

is always a new instance.  The behavior that I expected (perhaps a wrong
assumption) is that the initialization code would
use a shared HTTPConduit instance just as it does when I derive my WebClient
instance from a client defined in spring via <jaxrs:client/>

It looks like ConduitSelector is what I'm after to get this behavior.  That
is, I can set a ConduitSelector on the JAXRSClientFactoryBean that can be
used to resolve the conduit.

I understand why it works this way.  But intuitively, I expected the
instances to inherit the "global" configuration from the spring-managed CXF
runtime.

RS

On Wed, Jan 6, 2010 at 3:44 AM, Sergey Beryozkin <sberyozk@progress.com>wrote:

> Hi
>
> Have a look please here :
>
>
> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
>
> WebClients and proxies are initialized with a Spring configuration file, in
> fact, JAXRSClientFactoryBean is initialized with a spring-loaded bus under
> the hood, please
> see getBean() in
>
> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
>
> Does it help ?
> Sergey
>
>
> -----Original Message-----
> From: Rob Schoening [mailto:robschoening@gmail.com]
> Sent: Wed 1/6/2010 5:40 AM
> To: users@cxf.apache.org
> Subject: WebClient & Spring
>
> Is there a way to instantiate a WebClient instance programmatically such
> that it is bound to a Spring-configured CXF instance?  Ideally one should
> be
> able to pass in either a Bus or ApplicationContext instance.
> JAXRSClientFactoryBean does have a setBus() method, but setting the
> spring-instantiated bus instance doesn't seem to do the trick.
>
> The problem is that the manually instantiated WebClient instances don't
> pick
> up HTTPConduit configuration from spring.  In fact, it seems to create a
> new
> HTTPConduit for each WebClient instance, which I found to be surprising.
>  As
> it stands, the only way I seem to be able to get a "fully configured"
> wired-to-spring-instantiated-cxf WebClient is to call
> WebClient.fromClient()
> on the spring-managed Client instance for a given <jaxrs:client>.
>
> It works, but seems needlessly clunky.  Surely there is a better way...
>
> Cheers,
>
> Rob
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message