Le 13/10/2010 23:21, Daniel Kulp a écrit :
On Wednesday 13 October 2010 9:34:27 am Guillaume Sauthier wrote:
Hi team
I've found plenty of examples over the internet explaining how to setup
an HTTP proxy (using Spring or the API).
This is always done on a per-service basis.
I was wondering why the http.proxy* System properties were not used for
supporting this ?
This is: https://issues.apache.org/jira/browse/CXF-2839
Oops missed that issue ...
So, I come here to discuss this point.
Could it be possible (currently I'm not sure, but maybe as an evolution)
to provide the proxy configuration as some kind of global variable for
all the services (maybe as a per-bus configuration), but with support
for nonProxyHost (or the like) ?
WDYT ?
I think this could be done via an interceptor as well. An interceptor run
very early in the chain could grab the conduit and reconfigure the proxy stuff
fairly easily based on the URL it's going to hit.
The other way to handle this, which is how JBoss does this I believe, is to
set their own Configurer on the bus that wrappers the original one and has
configureBean methods that, if the bean is an HTTPConduit, completely
configures the conduit based on information from the app servers configs.
Really, that is the ideal way for app servers and containers and such to
configure the various parts of CXF as CXF uses that mechanism to configure
itself.
OK I get your point.
But how this solution (not interceptor based) can handle the issue of
the client changing the endpoint address after it has retrieved the port
proxy ?
After reading the code, it seems that the real URL is finally known
during HTTPConduit.prepare(Message) (more precisely in
HTTPConduit.setupUrl() ), so using an Interceptor will probably not help :'(
Then the URL is passed to an HttpConnectionFactory along with a Proxy
instance (created from the proxy information in the Conduit's config)
After some more thinking I think my solution will be something like:
* Configure the HTTPConduit using the Configurer extension to propagate
the System HTTP proxy properties
* Provides a new HttpUrlConnectionFactory that will act as a proxy and
nullify the Proxy reference (given as param) if the URL endpoint is one
of the hosts filtered by http.nonProxyHosts before delegating to the
real HttpUrlConnectionFactory
// Theses 2 first points could be contributed back directly to CXF
* Indeed, for JOnAS I'll have to intercept the HTTPConduit creation with
my own HTTPConduit subclass that will return my own
HttpUrlConnectionFactory.
// This last part could be introduced directly into CXF HTTPConduit if
you're ok with this (directly using the
FilteringNonProxyHostsHttpUrlConnectionFactory - quite long name BTW :) )
WDYT ?
--G