avatar

950

Better handle temporary (i.e. not serialized) configuration settings.

by mrs, 09 Jun, 2009 08:01 PM
800 950  
3030   protected static Properties soleProperty = new Properties();
3131   protected static Properties displayProperty = null;
3232   protected static Properties mAuxProps = null;
33   protected static Properties mTempProps = null;
3334   protected static Runtime curRuntime = Runtime.getRuntime();
3435 
3536   protected static String _configFileName = null;
------
383384   public static void saveConfiguration(String outFile) {
384385     _configFileName = outFile;
385386     passwordFixup(soleProperty);
386     killAll("temp.");
387387 
388388     if (_configFileName != null) {
389389       saveArbitrary(_configFileName, soleProperty);
------
549549   }
550550 
551551   public static void setConfiguration(String key, String value) {
552     _anyUpdates = true;
553     soleProperty.setProperty(key, value);
552     if(key.startsWith("temp.")) {
553       if(mTempProps == null) mTempProps = new Properties();
554       mTempProps.setProperty(key, value);
555     } else {
556       _anyUpdates = true;
557       soleProperty.setProperty(key, value);
558     }
554559   }
555560 
556561   public static String queryConfiguration(String query, String inDefault) {
------
564569     if(soleProperty.getProperty("config.logging", "false").equals("true")) {
565570       System.out.println("Query: " + query);
566571     }
572     if(query.startsWith("temp.")) {
573       return mTempProps.getProperty(query, null);
574     }
567575     return soleProperty.getProperty(query, null);
568576   }
569577