comparison gnv/src/main/java/de/intevation/gnv/propertiesreader/PropertiesReaderFactory.java @ 3:d7b4a77ba892

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

http://dive4elements.wald.intevation.org