JBoss Community

Dynamic Proxy Discovery

created by G N in Beginner's Corner - View the full discussion

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

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community