Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReaderFactory.java @ 36:ad381cc47217
Format Code to max 80 Chars per Row
gnv/trunk@172 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 02 Oct 2009 08:54:13 +0000 |
parents | fe6a64545552 |
children | fccf90761825 |
comparison
equal
deleted
inserted
replaced
35:4405f31bbc30 | 36:ad381cc47217 |
---|---|
9 | 9 |
10 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
11 | 11 |
12 /** | 12 /** |
13 * @author Tim Englich <tim.englich@intevation.de> | 13 * @author Tim Englich <tim.englich@intevation.de> |
14 * | 14 * |
15 */ | 15 */ |
16 public class PropertiesReaderFactory { | 16 public class PropertiesReaderFactory { |
17 | 17 |
18 | |
19 | |
20 /** | 18 /** |
21 * the logger, used to log exceptions and additonaly information | 19 * the logger, used to log exceptions and additonaly information |
22 */ | 20 */ |
23 private static Logger log = Logger.getLogger(PropertiesReaderFactory.class); | 21 private static Logger log = Logger.getLogger(PropertiesReaderFactory.class); |
24 | 22 |
25 | |
26 /** | 23 /** |
27 * The singleton Instance of this Factory. | 24 * The singleton Instance of this Factory. |
28 */ | 25 */ |
29 private static PropertiesReaderFactory instance = null; | 26 private static PropertiesReaderFactory instance = null; |
30 | 27 |
31 /** | 28 /** |
32 * The ConnectionPool providing the Connections to the DatabaseBackends | 29 * The ConnectionPool providing the Connections to the DatabaseBackends |
33 */ | 30 */ |
34 private PropertiesReader propertiesReader = null; | 31 private PropertiesReader propertiesReader = null; |
32 | |
35 /** | 33 /** |
36 * Constructor | 34 * Constructor |
37 */ | 35 */ |
38 private PropertiesReaderFactory() { | 36 private PropertiesReaderFactory() { |
39 super(); | 37 super(); |
40 } | 38 } |
41 | 39 |
42 /** | 40 /** |
43 * This Method provides an singleton Instance of this Class. | 41 * This Method provides an singleton Instance of this Class. |
42 * | |
44 * @return an singleton Instance of this Class | 43 * @return an singleton Instance of this Class |
45 */ | 44 */ |
46 public static PropertiesReaderFactory getInstance(){ | 45 public static PropertiesReaderFactory getInstance() { |
47 if (instance == null){ | 46 if (instance == null) { |
48 instance = new PropertiesReaderFactory(); | 47 instance = new PropertiesReaderFactory(); |
49 } | 48 } |
50 return instance; | 49 return instance; |
51 } | 50 } |
52 | 51 |
53 | |
54 /** | 52 /** |
55 * Getting the ConnectionPool | 53 * Getting the ConnectionPool |
54 * | |
56 * @return the ConnectionPool | 55 * @return the ConnectionPool |
57 */ | 56 */ |
58 public PropertiesReader getPropertiesReader(){ | 57 public PropertiesReader getPropertiesReader() { |
59 return this.propertiesReader; | 58 return this.propertiesReader; |
60 } | 59 } |
61 | 60 |
62 /** | 61 /** |
63 * Getting the ConnectionPool | 62 * Getting the ConnectionPool |
64 * @param config The Config that should be read | 63 * |
64 * @param config | |
65 * The Config that should be read | |
65 */ | 66 */ |
66 public void initPropertiesReader(Object config){ | 67 public void initPropertiesReader(Object config) { |
67 if (config instanceof ServletConfig){ | 68 if (config instanceof ServletConfig) { |
68 this.propertiesReader = new ServletPropertiesReader((ServletConfig)config); | 69 this.propertiesReader = new ServletPropertiesReader( |
69 }else if (config instanceof Map){ | 70 (ServletConfig) config); |
70 this.propertiesReader = new MapPropertiesReader((Map<String, String>)config); | 71 } else if (config instanceof Map) { |
71 }else{ | 72 this.propertiesReader = new MapPropertiesReader( |
72 log.error("No PropertiesReader for Instance "+ config.getClass().getName()); | 73 (Map<String, String>) config); |
74 } else { | |
75 log.error("No PropertiesReader for Instance " | |
76 + config.getClass().getName()); | |
73 } | 77 } |
74 | 78 |
75 } | 79 } |
76 | 80 |
77 } | 81 } |