Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEConnectionPool.java @ 887:b757def3ff55
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
geo-backend/trunk@859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 09:45:05 +0000 |
parents | 8b442223741c |
children | e5e30090c37c |
line wrap: on
line source
package de.intevation.gnv.geobackend.sde.connectionpool; import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool; import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException; import java.sql.Connection; import java.util.Properties; import org.apache.commons.pool.PoolableObjectFactory; import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.log4j.Logger; /** *This is the ArcSDE specific implementation of the Interface ConnectionPool * * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> */ public class ArcSDEConnectionPool implements ConnectionPool { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger .getLogger(ArcSDEPoolableObjectFactory.class); /** * The Pool which stores the Connections to the ArcSDE Backend */ private GenericObjectPool pool = null; /** * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#closeConnection(java.lang.Object) */ public void closeConnection(Connection connection) throws ConnectionException { try { this.pool.returnObject(connection); } catch (Exception e) { log.error(e, e); throw new ConnectionException(e); } } /** * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#getConnection(java.lang.String) */ public synchronized Connection getConnection(String connectionID) throws ConnectionException { try { Object object = this.pool.borrowObject(); if (object instanceof Connection) { return (Connection) object; } else { throw new ConnectionException( "Created Object is not an java.sql.Connection"); } } catch (Exception e) { log.error(e, e); throw new ConnectionException(e); } } /** * @see de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool#initialize(java.util.Properties) */ public void initialize(Properties properties) { log.info("ArcSDEConnectionPool.initialize has been called"); log.info("ConnectionPool will be initialized"); PoolableObjectFactory poolableObjectFactory = new ArcSDEPoolableObjectFactory( properties); int maxActive = Integer.parseInt(properties.getProperty("maxActive", "10")); long maxWait = Long.parseLong(properties.getProperty("maxWait", "" + GenericObjectPool.DEFAULT_MAX_WAIT)); int maxIdle = Integer.parseInt(properties.getProperty("maxIdle", "" + GenericObjectPool.DEFAULT_MAX_IDLE)); int minIdle = Integer.parseInt(properties.getProperty("minIdle", "" + GenericObjectPool.DEFAULT_MIN_IDLE)); boolean testOnBorrow = Boolean.parseBoolean(properties.getProperty( "testOnBorrow", "" + GenericObjectPool.DEFAULT_TEST_ON_BORROW)); boolean testOnReturn = Boolean.parseBoolean(properties.getProperty( "testOnReturn", "" + GenericObjectPool.DEFAULT_TEST_ON_RETURN)); long timeBetweenEvictionRunsMillis = Long .parseLong(properties .getProperty( "timeBetweenEvictionRunsMillis", "" + GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS)); int numTestsPerEvictionRun = Integer.parseInt(properties.getProperty( "numTestsPerEvictionRun", "" + GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN)); long minEvictableIdleTimeMillis = Long .parseLong(properties .getProperty( "minEvictableIdleTimeMillis", "" + GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS)); boolean testWhileIdle = Boolean.parseBoolean(properties .getProperty("testWhileIdle", "" + GenericObjectPool.DEFAULT_TEST_WHILE_IDLE)); log.info("Maximum Number of active Connections: " + maxActive); log.info("Maximum Number of waiting: " + maxWait); log.info("Maximum Number of idle: " + maxIdle); log.info("Minimum Number of idle: " + minIdle); log.info("TestOnBorrow: " + testOnBorrow); log.info("TestOnReturn: " + testOnReturn); log.info("TimeBetweenEvictionRunsMillis: " + timeBetweenEvictionRunsMillis); log.info("NumTestsPerEvictionRun: " + numTestsPerEvictionRun); log.info("MinEvictableIdleTimeMillis: " + minEvictableIdleTimeMillis); log.info("TestWhileIdle: " + testWhileIdle); this.pool = new GenericObjectPool(poolableObjectFactory, maxActive, GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION, maxWait, maxIdle, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); } }