1
2
3
4
5
6
7 package org.astrogrid.config;
8
9 import java.util.Hashtable;
10
11 /***
12 * For those who might want to create multiple configuration <i>instances</i>,
13 * this factory can be used. NB multiple configuration <i>files</i> can be
14 * read into a single instance.
15 * <p>
16 * Alternatively use is SimpleConfig, a static Singleton for
17 * easy key/value property getting and setting.
18 * <p>
19 * If Astrogrid's config implementation changes, change this factory method.
20 * <p>
21 *
22 * @author M Hill
23 */
24
25
26 public class ConfigFactory
27 {
28 /*** Created PropertyConfig instances */
29 private static final Hashtable configs = new Hashtable();
30
31 /***
32 * Creates an instance of an XML/Document-based (ie XPath/Node list)
33 * configuration
34 * @param id specifies a particular instance
35 */
36 public static synchronized Config getConfig(Object id)
37 {
38 Config config = (Config) configs.get(id);
39
40 if (config == null) {
41 config = new FailbackConfig(id);
42 configs.put(id, config);
43 }
44
45 return config;
46 }
47
48 }
49