[Mrpostman-cvs] mrpostman/src/org/mrbook/mrpostman MrPostman.java,1.19,1.20
Brought to you by:
chris_humphreys,
mrbook
From: <chr...@us...> - 2004-01-15 10:35:20
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman In directory sc8-pr-cvs1:/tmp/cvs-serv13632/mrpostman/src/org/mrbook/mrpostman Modified Files: MrPostman.java Log Message: Removed static dependency on MrPostman. Fixed proxy setting bug. Index: MrPostman.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/MrPostman.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MrPostman.java 24 Apr 2003 22:30:32 -0000 1.19 --- MrPostman.java 15 Jan 2004 10:35:10 -0000 1.20 *************** *** 58,64 **** public static int DEFAULT_HELP_PORT = 22220; public static boolean DEFAULT_START_LOG = false; - private static MrPostman maininstance = null; private static HelpServer hs = null; ! public Preferences userprefs = null; private boolean serverRunning = false; private PopServer pops = null; --- 58,63 ---- public static int DEFAULT_HELP_PORT = 22220; public static boolean DEFAULT_START_LOG = false; private static HelpServer hs = null; ! private Preferences userprefs = null; private boolean serverRunning = false; private PopServer pops = null; *************** *** 69,79 **** MrPostman() { int port = 0; - maininstance = this; initPrefs(); port = getPropertyInt("ServerPort", DEFAULT_PORT); initModules(); ! try { ! pops = new PopServer(port); serverRunning = true; --- 68,78 ---- MrPostman() { int port = 0; initPrefs(); port = getPropertyInt("ServerPort", DEFAULT_PORT); initModules(); ! initialiseProxy(); ! try { ! pops = new PopServer(this, port); serverRunning = true; *************** *** 166,173 **** } - public static MrPostman getMainInstance() { - return maininstance; - } - public void startHelpServer() throws IOException { if (hs == null) { --- 165,168 ---- *************** *** 186,190 **** try { // start the help server... ! helpPort = getPropertyInt("HelpServerPort", DEFAULT_HELP_PORT); startHelpServer(); } catch (IOException e) { --- 181,185 ---- try { // start the help server... ! helpPort = getPropertyInt(MrPostmanGui.PREF_HELP_PORT, DEFAULT_HELP_PORT); startHelpServer(); } catch (IOException e) { *************** *** 333,335 **** --- 328,369 ---- logger.info("Finished starting application"); } + /** + * @return + */ + public Preferences getUserprefs() { + return userprefs; + } + + /** + * @param preferences + */ + public void setUserprefs(Preferences preferences) { + userprefs = preferences; + } + + private void initialiseProxy() { + logger.finest("initialiseProxy()"); + java.util.Properties systemProperties = System.getProperties(); + if (getUserprefs().getBoolean(MrPostmanGui.PREF_USE_PROXY, false)) { + String httpProxyAddr = getUserprefs().get(MrPostmanGui.PREF_PROXY_ADDR, null); + String httpProxyPort = getUserprefs().get(MrPostmanGui.PREF_PROXY_PORT, null); + systemProperties.setProperty("http.proxyHost", httpProxyAddr); + systemProperties.setProperty("http.proxyPort", httpProxyPort); + logger.info("Using HTTP proxy " + httpProxyAddr + ":" + httpProxyPort); + } else { + systemProperties.remove("http.proxyHost"); + systemProperties.remove("http.proxyPort"); + } + + if (getUserprefs().getBoolean(MrPostmanGui.PREF_USE_HTTPS_PROXY, false)) { + String httpsProxyAddr = getUserprefs().get(MrPostmanGui.PREF_HTTPS_PROXY_ADDR, null); + String httpsProxyPort = getUserprefs().get(MrPostmanGui.PREF_HTTPS_PROXY_PORT, null); + systemProperties.setProperty("https.proxyHost", httpsProxyAddr); + systemProperties.setProperty("https.proxyPort", httpsProxyPort); + logger.info("Using HTTPS proxy " + httpsProxyAddr + ":" + httpsProxyPort); + } else { + systemProperties.remove("https.proxyHost"); + systemProperties.remove("https.proxyPort"); + } + } } \ No newline at end of file |