protected void loadConfig() { if (FileUtil.resilientConfigFileExists(CONFIG_FILE)) { Map map = FileUtil.readResilientConfigFile(CONFIG_FILE); List list = (List) map.get("networks"); if (list != null) { for (int i = 0; i < list.size(); i++) { Map cnet_map = (Map) list.get(i); try { ContentNetworkImpl cn = ContentNetworkImpl.importFromBEncodedMapStatic(this, cnet_map); if (cn.getID() != ContentNetwork.CONTENT_NETWORK_VUZE) { networks.add(cn); } } catch (Throwable e) { log("Failed to load " + cnet_map, e); } } } } }
public void load(String filename) { Map data = FileUtil.readResilientConfigFile(filename, false); // horrendous recursive loading going on here due to logger + config depedencies. If already // loaded // then use the existing data as it might have already been written to... if (propertiesMap == null) { ConcurrentHashMapWrapper<String, Object> c_map = new ConcurrentHashMapWrapper<String, Object>(data.size() + 256, 0.75f, 8); c_map.putAll(data); propertiesMap = c_map; } /* * Can't do this yet. Sometimes, there's a default set to x, but the code * calls get..Parameter(..., y). y != x. When the user sets the the parameter * to x, we remove it from the list. Later, the get..Parameter(.., y) returns * y because there is no entry. * * The solution is to not allow get..Parameter(.., y) when there's a default * value. Another reason to not allow it is that having two defaults confuses * coders. * // Remove entries that are default. Saves memory, reduces // file size when saved again ConfigurationDefaults def = ConfigurationDefaults.getInstance(); Iterator it = new TreeSet(propertiesMap.keySet()).iterator(); while (it.hasNext()) { String key = (String)it.next(); Object defValue = def.getDefaultValueAsObject(key); if (defValue == null) continue; if (defValue instanceof Long) { int iDefValue = ((Long)defValue).intValue(); int iValue = getIntParameter(key, iDefValue); if (iValue == iDefValue) propertiesMap.remove(key); } if (defValue instanceof String) { String sDefValue = defValue.toString(); String sValue = getStringParameter(key, sDefValue); if (sValue.compareTo(sDefValue) == 0) propertiesMap.remove(key); } } */ }