1 3 27 28 30 package de.qfs.apps.qflog; 31 32 34 import java.io.File ; 35 import java.io.IOException ; 36 37 import java.util.Locale ; 38 import java.util.MissingResourceException ; 39 import java.util.PropertyResourceBundle ; 40 import java.util.ResourceBundle ; 41 42 import de.qfs.lib.command.CommandDistributor; 43 import de.qfs.lib.config.Configuration; 44 import de.qfs.lib.log.Log; 45 import de.qfs.lib.log.Logger; 46 import de.qfs.lib.option.IntegerOption; 47 import de.qfs.lib.option.OptionSet; 48 import de.qfs.lib.util.MapResourceBundle; 49 50 import de.qfs.apps.qflog.logview.LogView; 51 52 54 61 public class App 62 { 63 65 68 private final static Logger logger = new Logger (App.class); 69 70 73 private static App theApp = new App (); 74 75 78 private OptionSet options; 79 80 83 private MapResourceBundle resources; 84 85 88 private CommandDistributor cd = new CommandDistributor(); 89 90 93 private File configFile; 94 95 98 private String serverName; 99 100 103 private String serverHost; 104 105 107 109 112 private App() 113 { 114 if (logger.level >= Log.MTD) { 115 logger.log(Log.MTD, "App()", ""); 116 } 117 reloadResources(); 118 initOptions(); 119 } 120 121 123 125 130 public static App instance() 131 { 132 if (logger.level >= Log.MTD) { 133 logger.log(Log.MTD, "instance()", ""); 134 } 135 return theApp; 136 } 137 138 139 141 146 151 public final static MapResourceBundle getResources() 152 { 153 if (logger.level >= Log.MTD) { 154 logger.log(Log.MTD, "getResources()", ""); 155 } 156 return instance()._getResources(); 157 } 158 159 162 167 public static CommandDistributor getCommandDistributor() 168 { 169 return instance()._getCommandDistributor(); 170 } 171 172 175 180 public static OptionSet getOptions() 181 { 182 return instance()._getOptions(); 183 } 184 185 187 192 197 private final MapResourceBundle _getResources() 198 { 199 return resources; 200 } 201 202 205 210 private final CommandDistributor _getCommandDistributor() 211 { 212 return cd; 213 } 214 215 218 223 private final OptionSet _getOptions() 224 { 225 return options; 226 } 227 228 230 232 235 public void reloadResources () 236 { 237 if (logger.level >= Log.MTD) { 238 logger.log(Log.MTD, "reloadResources()", ""); 239 } 240 try { 241 resources = new MapResourceBundle(); 242 ((MapResourceBundle)resources).fetchProperties 243 ("/de/qfs/lib/resources/properties/qflib", 244 MapResourceBundle.class); 245 ((MapResourceBundle)resources).fetchProperties 246 ("/de/qfs/apps/qflog/logview/resources/properties/logview", 247 LogView.class); 248 ((MapResourceBundle)resources).fetchProperties 249 ("/de/qfs/apps/qflog/logview/resources/properties/loglevelview", 250 LogView.class); 251 ((MapResourceBundle)resources).fetchProperties 252 ("/de/qfs/apps/qflog/logview/resources/properties/logtableview", 253 LogView.class); 254 ((MapResourceBundle)resources).fetchProperties 255 ("/de/qfs/apps/qflog/resources/properties/logserver", 256 getClass()); 257 } catch (MissingResourceException ex) { 258 if (logger.level >= Log.ERR) { 259 logger.log("reloadResources()", ex); 260 } 261 } 262 } 263 264 266 268 273 public final File getConfigFile() 274 { 275 return configFile; 276 } 277 278 281 286 public final void setConfigFile(File configFile) 287 { 288 this.configFile = configFile; 289 } 290 291 294 299 public final String getServerName() 300 { 301 return serverName; 302 } 303 304 307 312 public final void setServerName(String serverName) 313 { 314 this.serverName = serverName; 315 } 316 317 320 325 public final String getServerHost() 326 { 327 return serverHost; 328 } 329 330 333 338 public final void setServerHost(String serverHost) 339 { 340 this.serverHost = serverHost; 341 } 342 343 345 347 350 private void initOptions() 351 { 352 options = new OptionSet ("LogServer Options"); 353 options.add(new IntegerOption ("maxClients", 4)); 354 options.add(new IntegerOption ("maxNamedClients", 2)); 355 options.add(new IntegerOption ("maxDeadClients", 2)); 356 options.add(new IntegerOption ("maxDeadNamedClients", 1)); 357 Configuration.instance().register(options); 358 } 359 360 } 362 | Popular Tags |