1 14 15 package org.quickserver.util.xmlreader; 16 17 import org.apache.commons.digester.*; 18 import java.io.*; 19 import java.util.*; 20 import org.quickserver.util.*; 21 import org.quickserver.util.io.*; 22 import java.util.logging.*; 23 import org.quickserver.swing.*; 24 import org.quickserver.net.server.QuickServer; 25 26 32 public class ConfigReader { 33 private static Logger logger = Logger.getLogger(ConfigReader.class.getName()); 34 35 39 public static QuickServerConfig read(String fileName) throws Exception { 40 File input = new File(fileName); 41 return read(input); 42 } 43 44 48 public static QuickServerConfig read(File input) throws Exception { 49 Digester digester = new Digester(); 50 digester.setValidating(false); 51 52 String mainTag = "quickserver"; 56 String subTag = ""; 57 58 digester.addObjectCreate(mainTag, QuickServerConfig.class); 59 digester.addBeanPropertySetter(mainTag+"/name", "name"); 60 digester.addBeanPropertySetter(mainTag+"/server-banner", "serverBanner"); 61 digester.addBeanPropertySetter(mainTag+"/port", "port"); 62 digester.addBeanPropertySetter(mainTag+"/bind-address", "bindAddr"); 63 String curTag = mainTag+"/server-mode"; 65 digester.addObjectCreate(curTag, ServerMode.class); 66 digester.addBeanPropertySetter(curTag+"/blocking", "blocking"); 67 digester.addSetNext(curTag,"setServerMode"); 68 digester.addBeanPropertySetter(mainTag+"/client-event-handler", "clientEventHandler"); digester.addBeanPropertySetter(mainTag+"/client-command-handler", "clientCommandHandler"); 71 digester.addBeanPropertySetter(mainTag+"/client-object-handler", "clientObjectHandler"); 72 digester.addBeanPropertySetter(mainTag+"/client-binary-handler", "clientBinaryHandler"); digester.addBeanPropertySetter(mainTag+"/client-write-handler", "clientWriteHandler"); digester.addBeanPropertySetter(mainTag+"/authenticator", "authenticator"); digester.addBeanPropertySetter(mainTag+"/client-authentication-handler", "clientAuthenticationHandler"); digester.addBeanPropertySetter(mainTag+"/client-data", "clientData"); 77 digester.addBeanPropertySetter(mainTag+"/client-extended-event-handler", "clientExtendedEventHandler"); digester.addBeanPropertySetter(mainTag+"/timeout", "timeout"); 79 digester.addBeanPropertySetter(mainTag+"/timeout-msg", "timeoutMsg"); 80 digester.addBeanPropertySetter(mainTag+"/max-auth-try", "maxAuthTry"); 81 digester.addBeanPropertySetter(mainTag+"/max-auth-try-msg", "maxAuthTryMsg"); 82 digester.addBeanPropertySetter(mainTag+"/max-connection", "maxConnection"); 83 digester.addBeanPropertySetter(mainTag+"/max-connection-msg", "maxConnectionMsg"); 84 digester.addBeanPropertySetter(mainTag+"/console-logging-level", "consoleLoggingLevel"); 85 digester.addBeanPropertySetter(mainTag+"/console-logging-formatter", "consoleLoggingFormatter"); 86 curTag = mainTag+"/default-data-mode"; 88 digester.addObjectCreate(curTag, DefaultDataMode.class); 89 digester.addBeanPropertySetter(curTag+"/data-type-in", "dataModeIn"); 90 digester.addBeanPropertySetter(curTag+"/data-type-out", "dataModeOut"); 91 digester.addSetNext(curTag,"setDefaultDataMode"); 92 curTag = mainTag+"/object-pool"; 95 digester.addObjectCreate(curTag, ObjectPoolConfig.class); 96 digester.addBeanPropertySetter(curTag+"/max-active", "maxActive"); 97 digester.addBeanPropertySetter(curTag+"/max-idle", "maxIdle"); 98 digester.addBeanPropertySetter(curTag+"/init-size", "initSize"); 99 digester.addBeanPropertySetter(curTag+"/pool-manager", "poolManager"); 100 digester.addObjectCreate(curTag+"/thread-object-pool", ThreadObjectPoolConfig.class); 102 digester.addBeanPropertySetter(curTag+"/thread-object-pool/max-active", "maxActive"); 103 digester.addBeanPropertySetter(curTag+"/thread-object-pool/max-idle", "maxIdle"); 104 digester.addBeanPropertySetter(curTag+"/thread-object-pool/init-size", "initSize"); 105 digester.addSetNext(curTag+"/thread-object-pool","setThreadObjectPoolConfig"); 106 digester.addObjectCreate(curTag+"/client-handler-object-pool", ClientHandlerObjectPoolConfig.class); 109 digester.addBeanPropertySetter(curTag+"/client-handler-object-pool/max-active", "maxActive"); 110 digester.addBeanPropertySetter(curTag+"/client-handler-object-pool/max-idle", "maxIdle"); 111 digester.addBeanPropertySetter(curTag+"/client-handler-object-pool/init-size", "initSize"); 112 digester.addSetNext(curTag+"/client-handler-object-pool","setClientHandlerObjectPoolConfig"); 113 digester.addObjectCreate(curTag+"/byte-buffer-object-pool", ByteBufferObjectPoolConfig.class); 116 digester.addBeanPropertySetter(curTag+"/byte-buffer-object-pool/max-active", "maxActive"); 117 digester.addBeanPropertySetter(curTag+"/byte-buffer-object-pool/max-idle", "maxIdle"); 118 digester.addBeanPropertySetter(curTag+"/byte-buffer-object-pool/init-size", "initSize"); 119 digester.addSetNext(curTag+"/byte-buffer-object-pool","setByteBufferObjectPoolConfig"); 120 digester.addObjectCreate(curTag+"/client-data-object-pool", ClientDataObjectPoolConfig.class); 123 digester.addBeanPropertySetter(curTag+"/client-data-object-pool/max-active", "maxActive"); 124 digester.addBeanPropertySetter(curTag+"/client-data-object-pool/max-idle", "maxIdle"); 125 digester.addBeanPropertySetter(curTag+"/client-data-object-pool/init-size", "initSize"); 126 digester.addSetNext(curTag+"/client-data-object-pool","setClientDataObjectPoolConfig"); 127 digester.addSetNext(curTag,"setObjectPoolConfig"); 129 digester.addBeanPropertySetter(mainTag+"/communication-logging/enable", "communicationLogging"); 132 digester.addBeanPropertySetter(mainTag+"/security-manager-class", "securityManagerClass"); 134 135 digester.addObjectCreate(mainTag+"/access-constraint", AccessConstraintConfig.class); 137 digester.addObjectCreate(mainTag+"/access-constraint/ip-filter", IpFilterConfig.class); 139 digester.addBeanPropertySetter(mainTag+"/access-constraint/ip-filter/enable", "enable"); 140 digester.addBeanPropertySetter(mainTag+"/access-constraint/ip-filter/allow-access", "allowAccess"); 141 digester.addCallMethod(mainTag+"/access-constraint/ip-filter/ip-collection/client-ip-address", "addClientIpAddress", 0); 143 digester.addSetNext(mainTag+"/access-constraint/ip-filter", "setIpFilterConfig"); 145 digester.addSetNext(mainTag+"/access-constraint", "setAccessConstraintConfig"); 147 149 digester.addBeanPropertySetter(mainTag+"/application-jar-path", "applicationJarPath"); 151 152 digester.addObjectCreate(mainTag+"/server-hooks", ServerHooks.class); 154 digester.addCallMethod(mainTag+"/server-hooks/class-name", "addClassName", 0); 155 digester.addSetNext(mainTag+"/server-hooks", "setServerHooks"); 156 158 curTag = mainTag+"/secure"; 160 digester.addObjectCreate(curTag, Secure.class); 161 digester.addBeanPropertySetter(curTag+"/enable", "enable"); 162 digester.addBeanPropertySetter(curTag+"/load", "load"); 163 digester.addBeanPropertySetter(curTag+"/port", "port"); 164 digester.addBeanPropertySetter(curTag+"/protocol", "protocol"); 165 digester.addBeanPropertySetter(curTag+"/client-auth-enable", "clientAuthEnable"); 166 digester.addObjectCreate(curTag+"/secure-store", SecureStore.class); 168 digester.addBeanPropertySetter(curTag+"/secure-store/type", "type"); 169 digester.addBeanPropertySetter(curTag+"/secure-store/algorithm", "algorithm"); 170 digester.addBeanPropertySetter(curTag+"/secure-store/provider", "provider"); 171 digester.addObjectCreate(curTag+"/secure-store/key-store-info", KeyStoreInfo.class); 173 digester.addBeanPropertySetter(curTag+"/secure-store/key-store-info/store-file", "storeFile"); 174 digester.addBeanPropertySetter(curTag+"/secure-store/key-store-info/store-password", "storePassword"); 175 digester.addBeanPropertySetter(curTag+"/secure-store/key-store-info/key-password", "keyPassword"); 176 digester.addSetNext(curTag+"/secure-store/key-store-info","setKeyStoreInfo"); 177 digester.addObjectCreate(curTag+"/secure-store/trust-store-info", TrustStoreInfo.class); 180 digester.addBeanPropertySetter(curTag+"/secure-store/trust-store-info/store-file", "storeFile"); 181 digester.addBeanPropertySetter(curTag+"/secure-store/trust-store-info/store-password", "storePassword"); 182 digester.addBeanPropertySetter(curTag+"/secure-store/trust-store-info/type", "type"); 183 digester.addBeanPropertySetter(curTag+"/secure-store/trust-store-info/provider", "provider"); 184 digester.addSetNext(curTag+"/secure-store/trust-store-info","setTrustStoreInfo"); 185 digester.addBeanPropertySetter(curTag+"/secure-store/secure-store-manager", "secureStoreManager"); 187 digester.addSetNext(curTag+"/secure-store","setSecureStore"); 188 digester.addSetNext(curTag,"setSecure"); 190 192 curTag = mainTag+"/advanced-settings"; 194 digester.addObjectCreate(curTag, AdvancedSettings.class); 195 digester.addBeanPropertySetter(curTag+"/charset", "charset"); 196 digester.addBeanPropertySetter(curTag+"/byte-buffer-size", "byteBufferSize"); 197 digester.addBeanPropertySetter(curTag+"/backlog", "backlog"); 198 digester.addBeanPropertySetter(curTag+"/use-direct-byte-buffer", "useDirectByteBuffer"); 199 digester.addBeanPropertySetter(curTag+"/socket-linger", "socketLinger"); 200 digester.addBeanPropertySetter(curTag+"/debug-non-blocking-mode", "debugNonBlockingMode"); 201 digester.addBeanPropertySetter(curTag+"/client-identifier", "clientIdentifier"); 202 digester.addBeanPropertySetter(curTag+"/qsobject-pool-maker", "qSObjectPoolMaker"); 203 digester.addBeanPropertySetter(curTag+"/max-threads-for-nio-write", "maxThreadsForNioWrite"); 204 digester.addSetNext(curTag,"setAdvancedSettings"); 205 207 subTag = "qsadmin-server"; 209 curTag = mainTag+"/"+subTag; 210 digester.addObjectCreate(curTag, QSAdminServerConfig.class); 211 digester.addBeanPropertySetter(curTag+"/name", "name"); 212 digester.addBeanPropertySetter(curTag+"/server-banner", "serverBanner"); 213 digester.addBeanPropertySetter(curTag+"/port", "port"); 214 digester.addObjectCreate(curTag+"/server-mode", ServerMode.class); 216 digester.addBeanPropertySetter(curTag+"/server-mode/blocking", "blocking"); 217 digester.addSetNext(curTag+"/server-mode","setServerMode"); 218 digester.addBeanPropertySetter(curTag+"/client-event-handler", "clientEventHandler"); 220 digester.addBeanPropertySetter(curTag+"/client-command-handler", "clientCommandHandler"); 221 digester.addBeanPropertySetter(curTag+"/client-object-handler", "clientObjectHandler"); 222 digester.addBeanPropertySetter(curTag+"/client-binary-handler", "clientBinaryHandler"); digester.addBeanPropertySetter(curTag+"/client-write-handler", "clientWriteHandler"); digester.addBeanPropertySetter(curTag+"/authenticator", "authenticator"); digester.addBeanPropertySetter(curTag+"/client-authentication-handler", "clientAuthenticationHandler"); digester.addBeanPropertySetter(curTag+"/client-data", "clientData"); 227 digester.addBeanPropertySetter(curTag+"/client-extended-event-handler", "clientExtendedEventHandler"); digester.addBeanPropertySetter(curTag+"/timeout", "timeout"); 229 digester.addBeanPropertySetter(curTag+"/max-auth-try", "maxAuthTry"); 230 digester.addBeanPropertySetter(curTag+"/max-auth-try-msg", "maxAuthTryMsg"); 231 digester.addBeanPropertySetter(curTag+"/timeout-msg", "timeoutMsg"); 232 digester.addBeanPropertySetter(curTag+"/max-connection", "maxConnection"); 233 digester.addBeanPropertySetter(curTag+"/max-connection-msg", "maxConnectionMsg"); 234 digester.addBeanPropertySetter(curTag+"/bind-address", "bindAddr"); 235 digester.addBeanPropertySetter(curTag+"/client-object-handler", "clientObjectHandler"); 236 digester.addBeanPropertySetter(curTag+"/console-logging-level", "consoleLoggingLevel"); 237 digester.addBeanPropertySetter(curTag+"/console-logging-formatter", "consoleLoggingFormatter"); 238 digester.addObjectCreate(curTag+"/default-data-mode", DefaultDataMode.class); 240 digester.addBeanPropertySetter(curTag+"/default-data-mode/data-type-in", "dataModeIn"); 241 digester.addBeanPropertySetter(curTag+"/default-data-mode/data-type-out", "dataModeOut"); 242 digester.addSetNext(curTag+"/default-data-mode","setDefaultDataMode"); 243 digester.addObjectCreate(curTag+"/object-pool", ObjectPoolConfig.class); 246 digester.addBeanPropertySetter(curTag+"/object-pool/max-active", "maxActive"); 247 digester.addBeanPropertySetter(curTag+"/object-pool/max-idle", "maxIdle"); 248 digester.addBeanPropertySetter(curTag+"/object-pool/init-size", "initSize"); 249 digester.addBeanPropertySetter(curTag+"/object-pool/pool-manager", "poolManager"); 250 digester.addObjectCreate(curTag+"/object-pool/thread-object-pool", ThreadObjectPoolConfig.class); 252 digester.addBeanPropertySetter(curTag+"/object-pool/thread-object-pool/max-active", "maxActive"); 253 digester.addBeanPropertySetter(curTag+"/object-pool/thread-object-pool/max-idle", "maxIdle"); 254 digester.addBeanPropertySetter(curTag+"/object-pool/thread-object-pool/init-size", "initSize"); 255 digester.addSetNext(curTag+"/object-pool/thread-object-pool","setThreadObjectPoolConfig"); 256 digester.addObjectCreate(curTag+"/object-pool/client-handler-object-pool", ClientHandlerObjectPoolConfig.class); 259 digester.addBeanPropertySetter(curTag+"/object-pool/client-handler-object-pool/max-active", "maxActive"); 260 digester.addBeanPropertySetter(curTag+"/object-pool/client-handler-object-pool/max-idle", "maxIdle"); 261 digester.addBeanPropertySetter(curTag+"/object-pool/client-handler-object-pool/init-size", "initSize"); 262 digester.addSetNext(curTag+"/object-pool/client-handler-object-pool","setClientHandlerObjectPoolConfig"); 263 digester.addObjectCreate(curTag+"/object-pool/byte-buffer-object-pool", ByteBufferObjectPoolConfig.class); 266 digester.addBeanPropertySetter(curTag+"/object-pool/byte-buffer-object-pool/max-active", "maxActive"); 267 digester.addBeanPropertySetter(curTag+"/object-pool/byte-buffer-object-pool/max-idle", "maxIdle"); 268 digester.addBeanPropertySetter(curTag+"/object-pool/byte-buffer-object-pool/init-size", "initSize"); 269 digester.addSetNext(curTag+"/object-pool/byte-buffer-object-pool","setByteBufferObjectPoolConfig"); 270 digester.addObjectCreate(curTag+"/object-pool/client-data-object-pool", ClientDataObjectPoolConfig.class); 273 digester.addBeanPropertySetter(curTag+"/object-pool/client-data-object-pool/max-active", "maxActive"); 274 digester.addBeanPropertySetter(curTag+"/object-pool/client-data-object-pool/max-idle", "maxIdle"); 275 digester.addBeanPropertySetter(curTag+"/object-pool/client-data-object-pool/init-size", "initSize"); 276 digester.addSetNext(curTag+"/object-pool/client-data-object-pool","setClientDataObjectPoolConfig"); 277 digester.addSetNext(curTag+"/object-pool", "setObjectPoolConfig"); 279 digester.addBeanPropertySetter(curTag+"/command-shell/enable", "commandShellEnable"); 282 digester.addBeanPropertySetter(curTag+"/command-shell/prompt-name", "commandShellPromptName"); 283 digester.addBeanPropertySetter(curTag+"/communication-logging/enable", "communicationLogging"); 286 digester.addObjectCreate(curTag+"/access-constraint", AccessConstraintConfig.class); 288 digester.addObjectCreate(curTag+"/access-constraint/ip-filter", IpFilterConfig.class); 290 digester.addBeanPropertySetter(curTag+"/access-constraint/ip-filter/enable", "enable"); 291 digester.addBeanPropertySetter(curTag+"/access-constraint/ip-filter/allow-access", "allowAccess"); 292 digester.addCallMethod(curTag+"/access-constraint/ip-filter/ip-collection/client-ip-address", "addClientIpAddress", 0); 294 digester.addSetNext(curTag+"/access-constraint/ip-filter", "setIpFilterConfig"); 296 digester.addSetNext(curTag+"/access-constraint", "setAccessConstraintConfig"); 298 digester.addObjectCreate(curTag+"/server-hooks", ServerHooks.class); 301 digester.addCallMethod(curTag+"/server-hooks/class-name", "addClassName", 0); 302 digester.addSetNext(curTag+"/server-hooks", "setServerHooks"); 303 305 digester.addObjectCreate(curTag+"/secure", Secure.class); 307 digester.addBeanPropertySetter(curTag+"/secure/enable", "enable"); 308 digester.addBeanPropertySetter(curTag+"/secure/load", "load"); 309 digester.addBeanPropertySetter(curTag+"/secure/port", "port"); 310 digester.addBeanPropertySetter(curTag+"/secure/protocol", "protocol"); 311 digester.addBeanPropertySetter(curTag+"/secure/client-auth-enable", "clientAuthEnable"); 312 digester.addObjectCreate(curTag+"/secure/secure-store", SecureStore.class); 314 digester.addBeanPropertySetter(curTag+"/secure/secure-store/type", "type"); 315 digester.addBeanPropertySetter(curTag+"/secure/secure-store/algorithm", "algorithm"); 316 digester.addBeanPropertySetter(curTag+"/secure/secure-store/provider", "provider"); 317 digester.addObjectCreate(curTag+"/secure/secure-store/key-store-info", KeyStoreInfo.class); 319 digester.addBeanPropertySetter(curTag+"/secure/secure-store/key-store-info/store-file", "storeFile"); 320 digester.addBeanPropertySetter(curTag+"/secure/secure-store/key-store-info/store-password", "storePassword"); 321 digester.addBeanPropertySetter(curTag+"/secure/secure-store/key-store-info/key-password", "keyPassword"); 322 digester.addSetNext(curTag+"/secure/secure-store/key-store-info","setKeyStoreInfo"); 323 digester.addObjectCreate(curTag+"/secure/secure-store/trust-store-info", TrustStoreInfo.class); 326 digester.addBeanPropertySetter(curTag+"/secure/secure-store/trust-store-info/store-file", "storeFile"); 327 digester.addBeanPropertySetter(curTag+"/secure/secure-store/trust-store-info/store-password", "storePassword"); 328 digester.addBeanPropertySetter(curTag+"/secure/secure-store/trust-store-info/type", "type"); 329 digester.addBeanPropertySetter(curTag+"/secure/secure-store/trust-store-info/provider", "provider"); 330 digester.addSetNext(curTag+"/secure/secure-store/trust-store-info","setTrustStoreInfo"); 331 digester.addBeanPropertySetter(curTag+"/secure/secure-store/secure-store-manager", "secureStoreManager"); 333 digester.addSetNext(curTag+"/secure/secure-store","setSecureStore"); 334 digester.addSetNext(curTag+"/secure","setSecure"); 336 digester.addBeanPropertySetter(curTag+"/command-plugin", "commandPlugin"); 338 digester.addObjectCreate(curTag+"/advanced-settings", AdvancedSettings.class); 340 digester.addBeanPropertySetter(curTag+"/advanced-settings/charset", "charset"); 341 digester.addBeanPropertySetter(curTag+"/advanced-settings/byte-buffer-size", "byteBufferSize"); 342 digester.addBeanPropertySetter(curTag+"/advanced-settings/backlog", "backlog"); 343 digester.addBeanPropertySetter(curTag+"/advanced-settings/use-direct-byte-buffer", "useDirectByteBuffer"); 344 digester.addBeanPropertySetter(curTag+"/advanced-settings/socket-linger", "socketLinger"); 345 digester.addBeanPropertySetter(curTag+"/advanced-settings/debug-non-blocking-mode", "debugNonBlockingMode"); 346 digester.addBeanPropertySetter(curTag+"/advanced-settings/client-identifier", "clientIdentifier"); 347 digester.addBeanPropertySetter(curTag+"/advanced-settings/qsobject-pool-maker", "qSObjectPoolMaker"); 348 digester.addBeanPropertySetter(curTag+"/advanced-settings/max-threads-for-nio-write", "maxThreadsForNioWrite"); 349 digester.addSetNext(curTag+"/advanced-settings","setAdvancedSettings"); 350 digester.addSetNext(curTag, "setQSAdminServerConfig"); 352 354 355 subTag = "db-object-pool"; 357 digester.addObjectCreate(mainTag+"/"+subTag, DBObjectPoolConfig.class); 358 digester.addObjectCreate(mainTag+"/"+subTag+"/database-connection-set", DatabaseConnectionSet.class); 360 curTag = mainTag+"/"+subTag+"/database-connection-set/database-connection"; 362 digester.addObjectCreate(curTag, DatabaseConnectionConfig.class); 363 digester.addBeanPropertySetter(curTag+"/id", "id"); 364 digester.addBeanPropertySetter(curTag+"/driver", "driver"); 365 digester.addBeanPropertySetter(curTag+"/url", "url"); 366 digester.addBeanPropertySetter(curTag+"/username", "username"); 367 digester.addBeanPropertySetter(curTag+"/password", "password"); 368 digester.addSetNext(curTag, "addDatabaseConnection"); 369 digester.addSetNext(mainTag+"/"+subTag+"/database-connection-set", "setDatabaseConnectionSet"); 371 curTag = mainTag+"/"+subTag+"/db-pool-util"; 374 digester.addBeanPropertySetter(curTag, "dbPoolUtil"); 375 digester.addSetNext(mainTag+"/"+subTag, "setDBObjectPoolConfig"); 377 379 380 subTag = "application-configuration"; 382 digester.addObjectCreate(mainTag+"/"+subTag, ApplicationConfiguration.class); 383 digester.addBeanPropertySetter(mainTag+"/"+subTag+"/prompt-type", "promptType"); 384 curTag = mainTag+"/"+subTag+"/"+"property"; 385 digester.addObjectCreate(curTag, Property.class); 386 digester.addBeanPropertySetter(curTag+"/property-name", "name"); 387 digester.addBeanPropertySetter(curTag+"/property-value", "value"); 388 digester.addSetNext(curTag, "addProperty"); 389 digester.addSetNext(mainTag+"/"+subTag, "setApplicationConfiguration"); 390 392 393 subTag = "init-server-hooks"; 395 digester.addObjectCreate(mainTag+"/"+subTag, InitServerHooks.class); 396 digester.addCallMethod(mainTag+"/"+subTag+"/class-name", 397 "addClassName", 0); 398 digester.addSetNext(mainTag+"/"+subTag, "setInitServerHooks"); 399 401 logger.fine("Loading config from xml file : " + input.getAbsolutePath()); 402 QuickServerConfig qsc = (QuickServerConfig) digester.parse(input); 403 qsc.setConfigFile(input.getAbsolutePath()); 404 405 loadMissingApplicationConfiguration(qsc); 406 407 QuickServer.setDebugNonBlockingMode(qsc.getAdvancedSettings().getDebugNonBlockingMode()); 408 409 return qsc; 410 } 411 412 private static void loadMissingApplicationConfiguration(QuickServerConfig qsc) 413 throws IOException { 414 ApplicationConfiguration ac = qsc.getApplicationConfiguration(); 415 if(ac==null) return; 416 417 Set propertyNames = ac.keySet(); 419 Iterator iterator = propertyNames.iterator(); 420 String key = null; 421 Object value = null; 422 char sv[] = null; 423 SensitiveInput sensitiveInput = null; 424 boolean guiPrompt = ac.getPromptType().equals("console")==false?true:false; 425 426 while(iterator.hasNext()) { 427 key = (String ) iterator.next(); 428 value = ac.get(key); 429 if(value==null) { 430 if(guiPrompt && sensitiveInput==null) { 431 sensitiveInput = new SensitiveInput( 432 qsc.getName()+" - Input Prompt"); 433 } 434 435 if(guiPrompt) 436 sv = sensitiveInput.getInput(key); 437 else 438 sv = PasswordField.getPassword("Input property value for "+key+" : "); 439 440 if(sv!=null) { 441 value = new String (sv); 442 ac.put(key, value); 443 } 444 value = null; 445 } 446 } 447 } 448 449 454 public static File makeAbsoluteToConfig(String fileName, 455 QuickServerConfig config) { 456 File file = new File(fileName); 457 if(config==null) return file; 458 if(file.isAbsolute()==false) { 459 String temp = config.getConfigFile(); 460 file = new File(temp); 461 temp = file.getParent() + File.separatorChar + fileName; 462 file = new File(temp); 463 } 464 return file; 465 } 466 } 467 | Popular Tags |