Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java @ 132:5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
geo-backend/trunk@12 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 04 Sep 2009 08:11:30 +0000 |
parents | e4eacd613356 |
children | 210716612c30 |
comparison
equal
deleted
inserted
replaced
131:d8ff739b9f3b | 132:5a583cff97ea |
---|---|
14 * This factory delivers Instances of the Interface ConnectionPool. | 14 * This factory delivers Instances of the Interface ConnectionPool. |
15 * @author Tim Englich <tim.englich@intevation.de> | 15 * @author Tim Englich <tim.englich@intevation.de> |
16 */ | 16 */ |
17 public class ConnectionPoolFactory { | 17 public class ConnectionPoolFactory { |
18 | 18 |
19 | 19 /** |
20 /** | |
21 * the logger, used to log exceptions and additonaly information | 20 * the logger, used to log exceptions and additonaly information |
22 */ | 21 */ |
23 private static Logger log = Logger.getLogger(ConnectionPoolFactory.class); | 22 private static Logger log = Logger.getLogger(ConnectionPoolFactory.class); |
24 | 23 |
25 | 24 |
26 /** | 25 /** |
27 * The singleton Instance of this Factory. | 26 * The singleton Instance of this Factory. |
28 */ | 27 */ |
29 private static ConnectionPoolFactory instance = null; | 28 private static ConnectionPoolFactory instance = null; |
30 | 29 |
31 /** | 30 /** |
32 * The ConnectionPool providing the Connections to the DatabaseBackends | 31 * The ConnectionPool providing the Connections to the DatabaseBackends |
33 */ | 32 */ |
34 private ConnectionPool connectionPool = null; | 33 private ConnectionPool connectionPool = null; |
35 | 34 |
36 /** | 35 /** |
37 * Basic-Constructor of this Class | 36 * Basic-Constructor of this Class |
38 */ | 37 */ |
39 private ConnectionPoolFactory() { | 38 private ConnectionPoolFactory() { |
40 super(); | 39 super(); |
41 } | 40 } |
42 | 41 |
43 | 42 /** |
44 /** | 43 * This Method provides an singleton Instance of this Class. |
45 * This Method provides an singleton Instance of this Class. | 44 * @return an singleton Instance of this Class |
46 * @return an singleton Instance of this Class | 45 */ |
47 */ | 46 public static ConnectionPoolFactory getInstance(){ |
48 public static ConnectionPoolFactory getInstance(){ | 47 if (instance == null){ |
49 if (instance == null){ | 48 instance = new ConnectionPoolFactory(); |
50 instance = new ConnectionPoolFactory(); | 49 } |
51 } | 50 return instance; |
52 return instance; | 51 } |
53 } | 52 |
54 | 53 |
55 | 54 /** |
56 /** | 55 * Getting the ConnectionPool |
57 * Getting the ConnectionPool | 56 * @return the ConnectionPool |
58 * @return the ConnectionPool | 57 */ |
59 */ | 58 public ConnectionPool getConnectionPool(){ |
60 public ConnectionPool getConnectionPool(){ | 59 return this.connectionPool; |
61 return this.connectionPool; | 60 } |
62 } | 61 |
63 | 62 /** |
64 | 63 * Initializes the ConnectionPool. |
65 /** | 64 * Should only be called once on system startup |
66 * Initializes the ConnectionPool. | 65 * @param properties the Properties for the Individual Configuration of the ConnectionPool |
67 * Should only be called once on system startup | 66 */ |
68 * @param properties the Properties for the Individual Configuration of the ConnectionPool | 67 public void initializeConnectionPool(Properties properties){ |
69 */ | 68 log.debug("ConnectionPoolFactory.initializeConnectionPool"); |
70 public void initializeConnectionPool(Properties properties){ | 69 if (this.connectionPool == null){ |
71 log.debug("ConnectionPoolFactory.initializeConnectionPool"); | 70 //TODO: Hier könnte anhand eines Flags die Instanz des Connectionpools umgeschaltet werden. |
72 if (this.connectionPool == null){ | 71 this.connectionPool = new ArcSDEConnectionPool(); |
73 //TODO: Hier könnte anhand eines Flags die Instanz des Connectionpools umgeschaltet werden. | 72 this.connectionPool.initialize(properties); |
74 this.connectionPool = new ArcSDEConnectionPool(); | 73 }else{ |
75 this.connectionPool.initialize(properties); | 74 log.warn("ConnectionPool already initialized"); |
76 }else{ | 75 } |
77 log.warn("ConnectionPool already initialized"); | 76 } |
78 } | 77 |
79 } | 78 /** |
80 | 79 * Checks if the ConnectionPool has already been initialized. |
81 /** | 80 * @return true if the ConnectionPool is initialized. |
82 * Checks if the ConnectionPool has already been initialized. | 81 */ |
83 * @return true if the ConnectionPool is initialized. | 82 public boolean isInitialized(){ |
84 */ | 83 return this.connectionPool != null; |
85 public boolean isInitialized(){ | 84 } |
86 return this.connectionPool != null; | |
87 } | |
88 } | 85 } |