0 Replies Latest reply on Feb 9, 2013 1:06 AM by G N

    Dynamic Proxy Discovery

    G N Newbie

      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.

       

      Unfortunately, the following code does not discover correct information.

       

      System.setProperty("java.net.useSystemProxies","true");

      List<Proxy>listProxies;

      try{

                listProxies=ProxySelector.getDefault().select(

                                    newURI("http://www.google.com/"));

       

                for(Proxyproxy:listProxies){

       

      InetSocketAddressaddr=(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(URISyntaxExceptione){

                log.error("Failedtoininitilzieproxysettings",e);

      }

       

       

      Thanks