Hi!
This is about accessing the HttpConduit when dealing with WebTargets. I know
from an earlier thread that one suggested solution is to use
WebClient.getConfig(target.request()) to get access to the
ClientConfiguration but I didn't like that way of doing it.
Initially, I thought it was possible to access the HttpConduit from a
Feature implementation like this.
public class MyFeature extends AbstractFeature {
@Override
public void initialize(org.apache.cxf.endpoint.Client client, Bus bus) {
((HTTPConduit) client.getConduit()).setAuthSupplier(new
MyAuthSupplier());
}
}
And then use MyFeature like this
client.register(new MyFeature());
WebTarget target = client.target("http://acme.com");
target.request().get();
But that didn't work. The MyFeature.initialize method was never invoked.
However, I found out that if I implemented a Feature method with another
signature, then that method was invoked.
@Override
public void initialize(InterceptorProvider interceptorProvider, Bus bus) {
ClientConfiguration conf = (ClientConfiguration) interceptorProvider;
//Nasty
conf.getHttpConduit().setAuthSupplier(new MyAuthSupplier());
}
As you can see, I was able to access the HttpConduit by use of a really
nasty typecast.
Spontaneously, I really think that it should be possible to explicitly
access the ClientConfiguration in a Feature.initialize methods.
What do you guys think? Are there better ways of doing this?
--
View this message in context:
http://cxf.547215.n5.nabble.com/HttpConduit-for-WebTarget-tp5773080.html
Sent from the cxf-user mailing list archive at Nabble.com.