1 19 20 package org.netbeans.modules.websvc.registry.util; 21 22 import java.util.prefs.Preferences ; 23 import org.openide.util.NbPreferences; 24 25 29 public class WebProxySetter { 30 31 private final Integer MANUAL_SET_PROXY = new Integer (2); 32 private final String PROXY_HOST = "http.proxyHost"; private final String PROXY_PORT = "http.proxyPort"; 35 private static WebProxySetter defaultInstance = new WebProxySetter(); 36 37 private static Preferences proxySettingsNode; 40 41 private WebProxySetter() { 42 proxySettingsNode = NbPreferences.root ().node ("/org/netbeans/core"); 43 assert proxySettingsNode != null; 44 } 45 46 public static WebProxySetter getInstance(){ 47 return defaultInstance; 48 } 49 50 51 public String getProxyHost() { 52 return proxySettingsNode.get ("proxyHttpHost", ""); 53 } 54 55 56 public String getProxyPort() { 57 return proxySettingsNode.get ("proxyHttpPort", ""); 58 } 59 60 61 public void setProxyConfiguration(String host, String port ) { 62 proxySettingsNode.putInt ("proxyType", MANUAL_SET_PROXY.intValue ()); 63 proxySettingsNode.put ("proxyHttpHost", host); 64 proxySettingsNode.put ("proxyHttpPort", port); 65 System.setProperty(PROXY_HOST, host); 67 System.setProperty(PROXY_PORT, port); 68 } 69 } 70 | Popular Tags |