[jboss-user] [Beginner's Corner] - Dynamic Proxy Discovery

G N do-not-reply at jboss.com
Sat Feb 9 01:03:08 EST 2013


G N [https://community.jboss.org/people/kgena] created the discussion

"Dynamic Proxy Discovery"

To view the discussion, visit: https://community.jboss.org/message/796862#796862

--------------------------------------------------------------
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
[https://community.jboss.org/message/796862#796862]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130209/979bbb89/attachment.html 


More information about the jboss-user mailing list