Hello
I have done some investigation a while ago, and found out the HTTPConduit object
is the same for all clients. I avoid changing conduit configuration on the fly.
Switching between SSL/non SSL connection factory is built in HTTPConduit via
custom patch posted in this mailinglist.
Just have a look at http.setClient(httpClientPolicy); internal code, if it uses
thread local anywhere. If not then its not thread safe.
Jaro
Marc Giger schrieb:
> Hi,
>
> Is the following code (copied from the user-docs) thread safe?
>
> import org.apache.cxf.endpoint.Client;
> import org.apache.cxf.frontend.ClientProxy;
> import org.apache.cxf.transport.http.HTTPConduit;
> import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
> ...
>
> URL wsdl = getClass().getResource("wsdl/greeting.wsdl");
> SOAPService service = new SOAPService(wsdl, serviceName);
> Greeter greeter = service.getPort(portName, Greeter.class);
>
> // Okay, are you sick of configuration files ?
> // This will show you how to configure the http conduit dynamically
> Client client = ClientProxy.getClient(greeter);
> HTTPConduit http = (HTTPConduit) client.getConduit();
>
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>
> httpClientPolicy.setConnectionTimeout(36000);
> httpClientPolicy.setAllowChunking(false);
> httpClientPolicy.setReceiveTimeout(32000);
>
> http.setClient(httpClientPolicy);
>
> ...
> greeter.sayHi("Hello");
>
>
> Not that I have found any issue with it, but I want to
> be sure that it's intended to be.
>
> The requirement is to invoke multiple Endpoints in parallel where
> every EP has its own configuration (SSL-Client-Authentication,
> timeouts, url, expect-100-continue, etc). The whole configuration
> must be made at runtime, because the EP aren't known at startup time.
>
> Thank you!
>
> Marc
>