Hi
I am using JBoss 4.2.3. Is there any way to dynamically discover HTTP proxy setting of the machine that hosts the JBoss server.
Unfortunatelly, the following code does not discover correct information.
|
| System.setProperty("java.net.useSystemProxies", "true"); |
|
| List<Proxy> listProxies; |
|
| try { |
|
|
| listProxies = ProxySelector.getDefault().select( |
|
|
|
|
| new URI("http://www.google.com/")); |
|
|
| for (Proxy proxy : listProxies) { |
|
|
|
|
|
|
|
|
| InetSocketAddress addr = (InetSocketAddress) proxy.address(); |
|
|
|
| if (addr != null) |
|
|
|
| { |
|
|
|
|
| System.setProperty("http.proxyHost", addr.getHostName()); |
|
|
|
|
| System.setProperty("http.proxyPort", addr.getPort()+""); |
|
|
|
|
| System.setProperty("https.proxyHost", addr.getHostName()); |
|
|
|
|
| System.setProperty("https.proxyPort", addr.getPort()+""); |
|
|
|
| } |
|
|
| } |
|
| } catch (URISyntaxException e) { |
|
|
| log.error("Failed to ininitilzie proxy settings", e); |
|
| } |
Thanks