comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEConnectionPool.java @ 130:e4eacd613356

Implementierung Datenzugriff auf die ArcSDE über java.sql. Methodiken ChangeLog wird nachgereicht da SubversionClientincompatiblitäten vorhanden sind. geo-backend/trunk@7 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 02 Sep 2009 15:15:52 +0000
parents
children e5379e129799
comparison
equal deleted inserted replaced
129:110e3ac1b7d2 130:e4eacd613356
1 package de.intevation.gnv.geobackend.sde.connectionpool;
2
3 import java.sql.Connection;
4 import java.util.Properties;
5
6 import org.apache.commons.pool.PoolableObjectFactory;
7 import org.apache.commons.pool.impl.GenericObjectPool;
8 import org.apache.log4j.Logger;
9
10 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool;
11 import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException;
12
13 /**
14 *This is the ArcSDE specific implementation of the Interface ConnectionPool
15 * @author Tim Englich <tim.englich@intevation.de>
16 */
17 public class ArcSDEConnectionPool implements ConnectionPool {
18
19 /**
20 * the logger, used to log exceptions and additonaly information
21 */
22 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class);
23
24 /**
25 * The Pool which stores the Connections to the ArcSDE Backend
26 */
27 private GenericObjectPool pool = null;
28
29 /**
30 * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#closeConnection(java.lang.Object)
31 */
32 public void closeConnection(Connection connection) throws ConnectionException {
33
34 try {
35 //TODO: Muss Connection geschlossen werden?
36 this.pool.returnObject(connection);
37 } catch (Exception e) {
38 log.error(e,e);
39 throw new ConnectionException(e);
40 }
41
42 }
43
44 /**
45 * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#getConnection(java.lang.String)
46 */
47 public synchronized Connection getConnection(String connectionID) throws ConnectionException{
48 try {
49 Object object = this.pool.borrowObject();
50
51 if (object instanceof Connection){
52 return (Connection)object;
53 }else{
54 throw new ConnectionException("Created Object is not an java.sql.Connection");
55 }
56
57 } catch (Exception e) {
58 log.error(e,e);
59 throw new ConnectionException(e);
60 }
61 }
62
63 /**
64 * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#initialize(java.util.Properties)
65 */
66 public void initialize(Properties properties) {
67 log.info("ArcSDEConnectionPool.initialize has been called");
68 log.info("ConnectionPool will be initialized");
69
70 PoolableObjectFactory poolableObjectFactory = new ArcSDEPoolableObjectFactory(properties);
71
72 int maxActive = Integer.parseInt(properties.getProperty("maxActive", "10"));
73
74 log.info("Maximum Number of active Connections: "+maxActive);
75 // TODO weitere Werte einparsen und setzen.
76
77 this.pool = new GenericObjectPool(poolableObjectFactory,maxActive);
78
79 }
80
81 }

http://dive4elements.wald.intevation.org