The requirement in my project specifies that I need to dynamically set different proxies for my rest-template. I read these proxy values from another service and if any change is made to the proxy settings - I have to adjust my resttemplate to use these proxy settings.
This is the common code through which proxy is set for resttemplate.
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
InetSocketAddress address = new InetSocketAddress(host,portNr);
Proxy proxy = new Proxy(Proxy.Type.HTTP,address);
factory.setProxy(proxy);
restTemplate.setRequestFactory(factory);
But given a resttemplate autowired in my controller - Is there a way by which I can get the proxy settings - proxyHost,proxyPort et al? This would help in debugging on whether the proxy changes made are actually injected to the rest template.
I tried something like
SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
requestFactory.getProxy(); //However there is only setProxy here and no getProxy