From 371fbb4deb456788192b3583561ca6633033925c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Jan 2012 20:23:38 +0100 Subject: [PATCH] just comment + shorter code in serverSwitch Signed-off-by: Marek Otahal --- source/de/anomic/server/serverSwitch.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java index 864fbc489..8adf78ce2 100644 --- a/source/de/anomic/server/serverSwitch.java +++ b/source/de/anomic/server/serverSwitch.java @@ -165,18 +165,18 @@ public class serverSwitch (int) getConfigLong("server.maxTrackingHostCount", 100)); } + /** + * get my public IP, either set statically or figure out dynamic + * @return + */ public String myPublicIP() { // if a static IP was configured, we have to return it here ... final String staticIP = getConfig("staticIP", ""); - if ( staticIP.length() > 0 ) { - return staticIP; - } + if ( !"".equals(staticIP) ) return staticIP; // otherwise we return the real IP address of this host final InetAddress pLIP = Domains.myPublicLocalIP(); - if ( pLIP != null ) { - return pLIP.getHostAddress(); - } + if ( pLIP != null ) return pLIP.getHostAddress(); return null; } @@ -189,6 +189,10 @@ public class serverSwitch return this.log; } + /** + * add whole map of key-value pairs to config + * @param otherConfigs + */ public void setConfig(final Map otherConfigs) { final Iterator> i = otherConfigs.entrySet().iterator(); Map.Entry entry; @@ -326,6 +330,9 @@ public class serverSwitch return this.configProps.keySet().iterator(); } + /** + * write the changes to permanent storage (File) + */ private void saveConfig() { ConcurrentMap configPropsCopy = new ConcurrentHashMap(); configPropsCopy.putAll(this.configProps); // avoid concurrency problems