1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package inc.che.common.config;
19
20
21
22 import inc.che.common.resource.ResourceManager;
23 import inc.che.common.resource.StringResources;
24 import inc.che.common.string.StringUtil;
25
26 import org.apache.log4j.Logger;
27
28 import java.awt.Color;
29
30 import java.io.File;
31 import java.io.IOException;
32
33 import java.text.ParseException;
34
35 import java.util.ArrayList;
36 import java.util.Enumeration;
37 import java.util.HashMap;
38 import java.util.Iterator;
39 import java.util.List;
40 import java.util.Locale;
41 import java.util.Properties;
42
43 /***
44 * <b>Klasse zur Speicherung von Konfigurationparametern</b>
45 * @version $Id: Config.java,v 1.1 2005/03/06 12:56:50 stevemcmee Exp $
46 * @author <address> Steve McMee <stevemcmee@users.sourceforge.net></address>
47 */
48 public class Config {
49 /*** CVS ID of this file */
50 public static final String CVS_ID = "$Id: Config.java,v 1.1 2005/03/06 12:56:50 stevemcmee Exp $";
51
52 /***
53 * logger instance for this class
54 */
55 private static Logger log = Logger.getLogger(Config.class);
56
57 /***
58 * The ResourceManager
59 */
60 private static ResourceManager resourceManager = ResourceManager
61 .getResourceManager(StringResources.TEXT_RESOURCES);
62
63 /*** System key for the default configuration File */
64 private static final String SYS_KEY
65 = StringResources.CONFIG_SYS_PROPERTY;
66
67 /*** System key for the default userspecific configuration File */
68 private static final String USER_SYS_KEY
69 = StringResources.CONFIG_USER_SYS_PROPERTY;
70
71 /*** the default configuration file */
72 private static File defaultConfigFile;
73
74 static {
75 if (System.getProperty(USER_SYS_KEY) != null) {
76 log.debug("Found Sysproperty " + USER_SYS_KEY + ":"
77 + System.getProperty(USER_SYS_KEY));
78 defaultConfigFile = new File(System.getProperty("user.home") + "/"
79 + System.getProperty(USER_SYS_KEY));
80 log.debug("defaultConfigFile:" + defaultConfigFile);
81 }
82
83 if (System.getProperty(SYS_KEY) != null) {
84 log.debug("Found Sysproperty " + SYS_KEY + ":"
85 + System.getProperty(SYS_KEY));
86 defaultConfigFile = new File(System.getProperty(SYS_KEY));
87 }
88
89 if (defaultConfigFile == null) {
90 System.err.println(resourceManager.getText("config_syskey_notset",
91 new String[] {SYS_KEY + " or " + USER_SYS_KEY }));
92 }
93 }
94
95 /*** the instances one for each configuration file*/
96 private static HashMap instances;
97
98 /*** holds the configuration parameters*/
99 private Properties props;
100
101 /*** the configuraton file */
102 private File confFile;
103
104 /*** the load for this config*/
105 private ConfigLoader loader;
106
107 /*** the listeners */
108 private List listeners;
109
110 /*** indicates if the configuration is watched*/
111 private boolean isWatched = false;
112
113
114
115
116 protected Config(File confFile) {
117 if (log.isDebugEnabled()) {
118 log.debug("Config(" + confFile + ")");
119 }
120
121 if (confFile == null) {
122 fatalExit(resourceManager.getText("config_load_error"));
123 }
124
125 if (!confFile.exists()) {
126
127 try {
128 confFile.createNewFile();
129 } catch (IOException e) {
130 e.printStackTrace();
131 fatalExit("Cannot create configuration file " + confFile, e);
132
133
134 }
135 }
136
137 if (log.isDebugEnabled()) {
138 log.debug(resourceManager.getText("create_config",
139 new String[] {confFile.getAbsolutePath() }));
140 }
141
142 this.confFile = confFile;
143 this.listeners = null;
144 load();
145 }
146
147 /***
148 * emptys the Configuration
149 */
150 void clear() {
151 if (log.isDebugEnabled()) {
152 log.debug("clear()");
153 }
154
155 if (instances != null) {
156 instances.remove(confFile);
157 }
158
159 this.props = null;
160 }
161
162 /***
163 * Stores the Configuration
164 */
165 public void store() throws IOException {
166 if (log.isDebugEnabled()) {
167 log.debug("store()");
168 }
169
170 if (this.loader != null) {
171 this.loader.storeProperties(this.confFile, this.props);
172 }
173 }
174
175 /***
176 * adds a listener to the Configuration
177 * @parem listener the listener to be added
178 */
179 public void addListener(ConfigListener listener) {
180 if (this.listeners == null) {
181 this.listeners = new ArrayList();
182 }
183
184 this.listeners.add(listener);
185 }
186
187 /***
188 * prints message and exit
189 * @param message message to print
190 */
191 private void fatalExit(String msg) {
192 fatalExit(msg, null);
193 }
194
195 /***
196 * prints message and exit
197 * @param message message to print
198 *@param extends Exception
199 */
200 private void fatalExit(String msg, Exception ex) {
201 if (log.isDebugEnabled()) {
202 log.debug("fatalExit(" + msg + ", " + ex + ")");
203 }
204
205 if (ex != null) {
206 ex.printStackTrace();
207 log.error(msg, ex);
208 } else {
209 log.error(msg);
210 }
211
212 System.err.println(msg);
213 log.error(resourceManager.getText("exit_system"));
214 System.err.println(resourceManager.getText("exit_system"));
215 System.exit(1);
216 }
217
218 /***
219 * set the default configuration file
220 * @param path path to the defualt configuration file
221 */
222 public static void setDefaultConfigFile(String path) {
223 if (log.isDebugEnabled()) {
224 log.debug("setDefaultConfigFile(" + path + ")");
225 }
226
227 defaultConfigFile = new File(path);
228 }
229
230
231
232
233 protected synchronized void load() {
234 if (log.isDebugEnabled()) {
235 log.debug("load()");
236 }
237
238 this.loader = ConfigLoader.createLoader(confFile);
239
240 try {
241 this.props = this.loader.loadProperties(confFile);
242 } catch (IOException ex) {
243 ex.printStackTrace();
244 throw new RuntimeException(resourceManager.getText(
245 "cannot_load_conf",
246 new String[] {confFile.getAbsolutePath() }));
247 }
248
249 if (log.isDebugEnabled()) {
250 log.debug("load:" + this);
251 }
252 }
253
254
255
256
257 protected synchronized void reload() {
258 if (log.isDebugEnabled()) {
259 log.debug("reload()");
260 }
261
262 try {
263 this.props = this.loader.loadProperties(confFile);
264 } catch (IOException ex) {
265 ex.printStackTrace();
266 throw new RuntimeException(resourceManager.getText(
267 "cannot_load_param",
268 new String[] {confFile.getAbsolutePath() }));
269 }
270
271 if (log.isDebugEnabled()) {
272 log.debug("reload:" + this);
273 }
274 }
275
276 /***
277 * get all Config instances
278 * @returns HashMap containing all Config instances key is the configFile
279 */
280 static HashMap getInstances() {
281 if (log.isDebugEnabled()) {
282 log.debug("getInstances()");
283 }
284
285 return instances;
286 }
287
288 /***
289 * determines if the configuration is watched
290 * @return true if the configuration is watched
291 */
292 public boolean isWatched() {
293 return isWatched;
294 }
295
296
297
298
299
300
301 public static Config getInstance(File confFile) {
302 if (log.isDebugEnabled()) {
303 log.debug("getInstance(" + confFile + ")");
304 }
305
306 Config instance = null;
307
308 if (instances == null) {
309 instances = new HashMap();
310 }
311
312 if (instances.get(confFile) == null) {
313 instance = new Config(confFile);
314 instances.put(confFile, instance);
315 }
316
317 return (Config) instances.get(confFile);
318 }
319
320
321
322
323
324
325 public static Config getInstance(String path) {
326 if (log.isDebugEnabled()) {
327 log.debug("getInstance(" + path + ")");
328 }
329
330 return getInstance(new File(path));
331 }
332
333
334
335
336
337 public static Config getInstance() {
338 if (log.isDebugEnabled()) {
339 log.debug("getInstance()");
340 }
341
342 return getInstance(defaultConfigFile);
343 }
344
345
346
347
348
349
350
351 public static Config getInstance(File confFile, long watchTime) {
352 if (log.isDebugEnabled()) {
353 log.debug("getInstance(" + confFile + "," + watchTime + ")");
354 }
355
356 Config instance = getInstance(confFile);
357
358 if (instance.isWatched) {
359 log.warn(resourceManager.getText("config_watched",
360 new String[] {
361 String.valueOf(confFile.getAbsoluteFile())
362 }));
363 } else {
364 instance.isWatched = true;
365 new ConfigThread(instance, watchTime).start();
366 }
367
368 return instance;
369 }
370
371
372
373
374
375
376
377 public static Config getInstance(String path, long watchTime) {
378 if (log.isDebugEnabled()) {
379 log.debug("getInstance(" + path + "," + watchTime + ")");
380 }
381
382 return getInstance(new File(path), watchTime);
383 }
384
385
386
387
388
389
390 public static Config getInstance(long watchTime) {
391 if (log.isDebugEnabled()) {
392 log.debug("getInstance(" + watchTime + ")");
393 }
394
395 return getInstance(defaultConfigFile, watchTime);
396 }
397
398 /***
399 * gets the configuration file for this instance
400 * @return the configuratoin file
401 */
402 public File getConfigFile() {
403 if (log.isDebugEnabled()) {
404 log.debug("getConfigFile()");
405 }
406
407 return this.confFile;
408 }
409
410 /***
411 * gets the listeners of the configuration
412 * @return the listeners
413 */
414 List getListeners() {
415 if (log.isDebugEnabled()) {
416 log.debug("getListeners()");
417 }
418
419 return this.listeners;
420 }
421
422 /***
423 * gets a configuration Parameter
424 * @param name the name of the configuration parameter
425 * @return the value of the configuraton parameter
426 */
427 public String internalGetParameter(String name) {
428 if (log.isDebugEnabled()) {
429 log.debug("internalGetParameter(" + name + ")");
430 }
431
432 return props.getProperty(name);
433 }
434
435 /***
436 * gets a configuration Parameter
437 * @param name the name of the configuration parameter
438 * @return the value of the configuraton parameter(default: null)
439 */
440 public String getParameter(String name) {
441 if (log.isDebugEnabled()) {
442 log.debug("getParameter(" + name + ")");
443 }
444
445 return getParameter(name, "");
446 }
447
448 /***
449 * gets a configuration Parameter
450 * @param name the name of the configuration parameter
451 * @param def default value if parameter doesn't exists
452 * @return the value of the configuraton parameter
453 */
454 public String getParameter(String name, String def) {
455 if (log.isDebugEnabled()) {
456 log.debug("getParameter(" + name + "," + def + ")");
457 }
458
459 return isSet(name) ? internalGetParameter(name)
460 : setParameter(name, def);
461 }
462
463 /***
464 * sets a configuration Parameter
465 * @param name the name of the configuration parameter
466 *@param value the vale to be set
467 * @return the value of the configuraton parameter
468 */
469 public String setParameter(String name, String value) {
470 if (log.isDebugEnabled()) {
471 log.debug("getParameter(" + name + ", " + value + ")");
472 }
473
474 props.setProperty(name, value);
475
476 return value;
477 }
478
479 /***
480 * gets a configuration Parameter as int
481 * @param name the name of the configuration parameter
482 * @return the value of the configuration parameter
483 */
484 public int internalGetIntParameter(String name) {
485 if (log.isDebugEnabled()) {
486 log.debug("internalGetIntParameter(" + name + ")");
487 }
488
489 return Integer.parseInt(props.getProperty(name));
490 }
491
492 /***
493 * gets a configuration Parameter as int
494 * @param name the name of the configuration parameter
495 * @return the value of the configuration parameter (default: 0)
496 */
497 public int getIntParameter(String name) {
498 if (log.isDebugEnabled()) {
499 log.debug("getIntParameter(" + name + ")");
500 }
501
502 return getIntParameter(name, 0);
503 }
504
505 /***
506 * gets a configuration Parameter as Locale
507 * @param name the name of the configuration parameter
508 * @return the value of the configuration parameter
509 */
510 public Locale internalGetLocaleParameter(String name) {
511 if (log.isDebugEnabled()) {
512 log.debug("internalGetLocaleParameter(" + name + ")");
513 }
514
515 return new Locale(props.getProperty(name));
516 }
517
518 /***
519 * gets a configuration Parameter as Locale
520 * @param name the name of the configuration parameter
521 * @return the value of the configuration parameter (default: Locale.getDefault())
522 */
523 public Locale getLocaleParameter(String name) {
524 if (log.isDebugEnabled()) {
525 log.debug("getLocaleParameter(" + name + ")");
526 }
527
528 return getLocaleParameter(name, Locale.getDefault());
529 }
530
531 /***
532 * gets a configuration Parameter as Locale
533 * @param name the name of the configuration parameter
534 * @return the value of the configuration parameter
535 */
536 public Locale getLocaleParameter(String name, Locale def) {
537 if (log.isDebugEnabled()) {
538 log.debug("getLocaleParameter(" + name + "," + def + ")");
539 }
540
541 return isSet(name) ? internalGetLocaleParameter(name)
542 : setLocaleParameter(name, def);
543 }
544
545 /***
546 * gets a configuration Parameter as int
547 * @param name the name of the configuration parameter
548 * @param def default value if parameter doesn't exists
549 * @return the value of the configuration parameter
550 */
551 public int getIntParameter(String name, int def) {
552 if (log.isDebugEnabled()) {
553 log.debug("getIntParameter(" + name + "," + def + ")");
554 }
555
556 return isSet(name) ? internalGetIntParameter(name)
557 : setIntParameter(name, def);
558 }
559
560 /***
561 * set a configuration Parameter with an int
562 * @param name the name of the configuration parameter
563 *@param value the vale to be set
564 * @return the value of the configuration parameter
565 */
566 public int setIntParameter(String name, int value) {
567 if (log.isDebugEnabled()) {
568 log.debug("setIntParameter(" + name + "," + value + ")");
569 }
570
571 props.setProperty(name, String.valueOf(value));
572
573 return value;
574 }
575
576 /***
577 * gets a configuration Parameter as boolean
578 * @param name the name of the configuration parameter
579 * @return the value of the configuraton parameter
580 */
581 public boolean internalGetBooleanParameter(String name) {
582 if (log.isDebugEnabled()) {
583 log.debug("internalGetBooleanParameter(" + name + ")");
584 }
585
586 return Boolean.valueOf(props.getProperty(name)).booleanValue();
587 }
588
589 /***
590 * gets a configuration Parameter as boolean
591 * @param name the name of the configuration parameter
592 * @return the value of the configuraton parameter (default: false)
593 */
594 public boolean getBooleanParameter(String name) {
595 if (log.isDebugEnabled()) {
596 log.debug("getBooleanParameter(" + name + ")");
597 }
598
599 return getBooleanParameter(name, false);
600 }
601
602 /***
603 * gets a configuration Parameter as boolean
604 * @param name the name of the configuration parameter
605 * @param def default value if parameter doesn't exists
606 * @return the value of the configuraton parameter
607 */
608 public boolean getBooleanParameter(String name, boolean def) {
609 if (log.isDebugEnabled()) {
610 log.debug("getBooleanParameter(" + name + "," + def + ")");
611 }
612
613 return isSet(name) ? internalGetBooleanParameter(name)
614 : setBooleanParameter(name, def);
615 }
616
617 /***
618 * set a configuration Parameter with boolean
619 * @param name the name of the configuration parameter
620 *@param value the value to be set
621 * @return the value of the configuration parameter
622 */
623 public boolean setBooleanParameter(String name, boolean value) {
624 if (log.isDebugEnabled()) {
625 log.debug("setBooleanParameter(" + name + "," + value + ")");
626 }
627
628 props.setProperty(name, String.valueOf(value));
629
630 return value;
631 }
632
633 /***
634 * gets a configuration Parameter as double
635 * @param name the name of the configuration parameter
636 * @return the value of the configuraton parameter
637 */
638 public double internalGetDoubleParameter(String name) {
639 if (log.isDebugEnabled()) {
640 log.debug("internalGetDoubleParameter(" + name + ")");
641 }
642
643 return Double.parseDouble((props.getProperty(name)));
644 }
645
646 /***
647 * gets a configuration Parameter as double
648 * @param name the name of the configuration parameter
649 * @return the value of the configuraton parameter (default: 0.0)
650 */
651 public double getDoubleParameter(String name) {
652 if (log.isDebugEnabled()) {
653 log.debug("getDoubleParameter(" + name + ")");
654 }
655
656 return getDoubleParameter(name, 0.0);
657 }
658
659 /***
660 * gets a configuration Parameter as double
661 * @param name the name of the configuration parameter
662 * @param def default value if parameter doesn't exists
663 * @return the value of the configuraton parameter
664 */
665 public double getDoubleParameter(String name, double def) {
666 if (log.isDebugEnabled()) {
667 log.debug("getDoubleParameter(" + name + "," + def + ")");
668 }
669
670 return isSet(name) ? internalGetDoubleParameter(name)
671 : setDoubleParameter(name, def);
672 }
673
674 /***
675 * set a configuration Parameter with a double
676 * @param name the name of the configuration parameter
677 *@param value the value to be set
678 * @return the value of the configuration parameter
679 */
680 public double setDoubleParameter(String name, double value) {
681 if (log.isDebugEnabled()) {
682 log.debug("setDoubleParameter(" + name + "," + value + ")");
683 }
684
685 props.setProperty(name, String.valueOf(value));
686
687 return value;
688 }
689
690 /***
691 * set a configuration Parameter with a Locale
692 * @param name the name of the configuration parameter
693 *@param value the value to be set
694 * @return the value of the configuration parameter
695 */
696 public Locale setLocaleParameter(String name, Locale value) {
697 if (log.isDebugEnabled()) {
698 log.debug("setLocaleParameter(" + name + "," + value + ")");
699 }
700
701 props.setProperty(name, value.getLanguage());
702
703 return value;
704 }
705
706 /***
707 * gets a configuration Parameter as Color
708 * @param name the name of the configuration parameter
709 * @return the color represented by name Colors must be given as #RRGGBB
710 */
711 public Color internalGetColorParameter(String name) {
712 if (log.isDebugEnabled()) {
713 log.debug("internalGetColorParameter(" + name + ")");
714 }
715
716 Color color = Color.BLACK;
717
718 try {
719 color = StringUtil.toColor(props.getProperty(name));
720 } catch (java.text.ParseException ex) {
721 ex.printStackTrace();
722 log.error(resourceManager.getText("wrong_color_param",
723 new String[] {name}), ex);
724 }
725
726 return color;
727 }
728
729 /***
730 * gets a configuration Parameter as Color
731 * @param name the name of the configuration parameter
732 * @return the color represented by name Colors must be given as #RRGGBB (default: Color.BLACK)
733 */
734 public Color getColorParameter(String name) {
735 if (log.isDebugEnabled()) {
736 log.debug("getColorParameter(" + name + ")");
737 }
738
739 return getColorParameter(name, Color.BLACK);
740 }
741
742 /***
743 * gets a configuration Parameter as Color
744 * @param name the name of the configuration parameter
745 * @param def default value if parameter doesn't exists
746 * @return the color represented by name Colors must be given as #RRGGBB
747 */
748 public Color getColorParameter(String name, Color def) {
749 if (log.isDebugEnabled()) {
750 log.debug("getColorParameter(" + name + "," + def + ")");
751 }
752
753 Color ret = def;
754
755 if (isSet(name)) {
756 ret = internalGetColorParameter(name);
757 } else {
758 try {
759 ret = setColorParameter(name, def);
760 } catch (ParseException ex) {
761 ex.printStackTrace();
762 }
763 }
764
765 return ret;
766 }
767
768 /***
769 * set a configuration Parameter with a Color
770 * @param name the name of the configuration parameter
771 *@param value the value to be set
772 * @return the value of the configuration parameter
773 */
774 public Color setColorParameter(String name, Color value)
775 throws ParseException {
776 if (log.isDebugEnabled()) {
777 log.debug("setColorParameter(" + name + "," + value + ")");
778 }
779
780 props.setProperty(name, StringUtil.toRgbString(value));
781
782 return value;
783 }
784
785 /***
786 * gets a configuration Parameter as File
787 * @param name the name of the configuration parameter
788 * @return the value of the configuration parameter
789 */
790 public File internalGetFileParameter(String name) {
791 if (log.isDebugEnabled()) {
792 log.debug("internalGetFileParameter(" + name + ")");
793 }
794
795 return new File(props.getProperty(name));
796 }
797
798 /***
799 * gets a configuration Parameter as File
800 * @param name the name of the configuration parameter
801 * @return the value of the configuration parameter (default user.home)
802 */
803 public File getFileParameter(String name) {
804 if (log.isDebugEnabled()) {
805 log.debug("getFileParameter(" + name + ")");
806 }
807
808 return getFileParameter(name,
809 new File(System.getProperty("user.home")));
810 }
811
812 /***
813 * gets a configuration Parameter as File
814 * @param name the name of the configuration parameter
815 * @param def default value if parameter doesn't exists
816 * @return the value of the configuration parameter
817 */
818 public File getFileParameter(String name, File def) {
819 if (log.isDebugEnabled()) {
820 log.debug("getFileParameter(" + name + "," + def + ")");
821 }
822
823 File ret = def;
824
825 if (isSet(name)) {
826 ret = internalGetFileParameter(name);
827 } else {
828 try {
829 ret = setFileParameter(name, def);
830 } catch (ParseException ex) {
831 ex.printStackTrace();
832 }
833 }
834
835 return ret;
836 }
837
838 /***
839 * set a configuration Parameter with a File
840 * @param name the name of the configuration parameter
841 *@param value the value to be set
842 * @return the value of the configuration parameter
843 */
844 public File setFileParameter(String name, File value)
845 throws ParseException {
846 if (log.isDebugEnabled()) {
847 log.debug("setFileParameter(" + name + "," + value + ")");
848 }
849
850 props.setProperty(name, value.getAbsolutePath());
851
852 return value;
853 }
854
855 /***
856 * checks wheter a parameter is set or not
857 * @param name the name of the configuration parameter
858 * @return true if the parameter is set in the configuration file
859 */
860 public boolean isSet(String name) {
861 if (log.isDebugEnabled()) {
862 log.debug("isSet(" + name + ")");
863 }
864
865 return (internalGetParameter(name) != null);
866 }
867
868 /***
869 * get string representation of the class
870 * @return string representation of the class show all parameter an their valus
871 */
872 public String toString() {
873 if (log.isDebugEnabled()) {
874 log.debug("toString()");
875 }
876
877 StringBuffer buffer = new StringBuffer();
878
879 buffer.append("confFile:").append(confFile).append("\n");
880 buffer.append("loader:").append(loader.getClass()).append("\n");
881 buffer.append("properties:").append("\n");
882
883 for (Iterator it = this.props.keySet().iterator(); it.hasNext();) {
884 String key = (String) it.next();
885 buffer.append(key).append(":")
886 .append(props.getProperty(key)).append("\n");
887 }
888
889 return buffer.toString();
890 }
891
892 /***
893 * DOCUMENT ME!
894 *
895 * @return DOCUMENT ME!
896 */
897 public Enumeration parameters() {
898 return props.keys();
899 }
900 }
901
902
903 /***
904 * DOCUMENT ME!
905 *
906 * @author $author$
907 * @version $Revision: 1.1 $
908 */
909 class ConfigThread extends Thread {
910 /*** DOCUMENT ME! */
911 private static Logger log = Logger.getLogger(ConfigThread.class);
912
913 /***
914 * The ResourceManager
915 */
916 private static ResourceManager resourceManager = ResourceManager
917 .getResourceManager(StringResources.TEXT_RESOURCES);
918
919 /*** DOCUMENT ME! */
920 private Config config;
921
922 /*** DOCUMENT ME! */
923 private long wait;
924
925 /***
926 * Creates a new ConfigThread object.
927 *
928 * @param config DOCUMENT ME!
929 * @param wait DOCUMENT ME!
930 */
931 ConfigThread(Config config, long wait) {
932 if (log.isDebugEnabled()) {
933 log.debug("ConfigThread(" + config + "," + wait + ")");
934 }
935
936 this.config = config;
937 this.wait = wait;
938 }
939
940 /***
941 * DOCUMENT ME!
942 */
943 public void run() {
944 if (log.isDebugEnabled()) {
945 log.debug("run()");
946 }
947
948 File file = config.getConfigFile();
949 long last = file.lastModified();
950
951 while (true) {
952 long newlastmod = file.lastModified();
953
954 if (last < newlastmod) {
955 if (log.isDebugEnabled()) {
956 log.debug(resourceManager.getText("relaod_param"));
957 }
958
959 last = newlastmod;
960
961
962 config.reload();
963
964 if (config.getListeners() != null) {
965 for (Iterator it = config.getListeners().iterator();
966 it.hasNext();) {
967 ((ConfigListener) it.next()).configChanged(config);
968 }
969 }
970 }
971
972 try {
973 Thread.sleep(wait);
974 } catch (Exception ex) {
975 ex.printStackTrace();
976 log.fatal("Error in run() ", ex);
977 }
978 }
979 }
980 }