commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp BasicDataSource.java BasicDataSourceFactory.java
Date Thu, 06 Mar 2003 14:58:42 GMT
rwaldhoff    2003/03/06 06:58:42

  Modified:    dbcp/src/java/org/apache/commons/dbcp BasicDataSource.java
                        BasicDataSourceFactory.java
  Log:
  Apply Gerald Turner's patch that exposes idle eviction parameters in BasicDataSource/BasicDataSourceFactory
  This closes bug 16581 <http://issues.apache.org/bugzilla/show_bug.cgi?id=16581>
  Thanks Gerald!
  
  Revision  Changes    Path
  1.12      +102 -4    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java
  
  Index: BasicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BasicDataSource.java	21 Jul 2002 00:38:35 -0000	1.11
  +++ BasicDataSource.java	6 Mar 2003 14:58:42 -0000	1.12
  @@ -177,7 +177,98 @@
           this.maxWait = maxWait;
       }
   
  +    /**
  +     * The indication of whether objects will be validated before being
  +     * borrowed from the pool.  If the object fails to validate, it will be
  +     * dropped from the pool, and we will attempt to borrow another.
  +     */
  +    protected boolean testOnBorrow = GenericObjectPool.DEFAULT_TEST_ON_BORROW;
  +
  +    public boolean getTestOnBorrow() {
  +        return (this.testOnBorrow);
  +    }
  +
  +    public void setTestOnBorrow(boolean testOnBorrow) {
  +        this.testOnBorrow = testOnBorrow;
  +    }
  +
  +    /**
  +     * The indication of whether objects will be validated before being
  +     * returned to the pool.
  +     */
  +    protected boolean testOnReturn =  GenericObjectPool.DEFAULT_TEST_ON_RETURN;
  +
  +    public boolean getTestOnReturn() {
  +        return (this.testOnReturn);
  +    }
  +
  +    public void setTestOnReturn(boolean testOnReturn) {
  +        this.testOnReturn = testOnReturn;
  +    }
  +
  +
  +    /**
  +     * The number of milliseconds to sleep between runs of the idle object
  +     * evictor thread.  When non-positive, no idle object evictor thread will
  +     * be run.
  +     */
  +    protected long timeBetweenEvictionRunsMillis =
  +        GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
  +        
  +    public long getTimeBetweenEvictionRunsMillis() {
  +        return (this.timeBetweenEvictionRunsMillis);
  +    }
  +
  +    public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
  +        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
  +    }
  +
   
  +    /**
  +     * The number of objects to examine during each run of the idle object
  +     * evictor thread (if any).
  +     */
  +    protected int numTestsPerEvictionRun =
  +        GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
  +
  +    public int getNumTestsPerEvictionRun() {
  +        return (this.numTestsPerEvictionRun);
  +    }
  +
  +    public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
  +        this.numTestsPerEvictionRun = numTestsPerEvictionRun;
  +    }
  +
  +
  +    /**
  +     * The minimum amount of time an object may sit idle in the pool before it
  +     * is eligable for eviction by the idle object evictor (if any).
  +     */
  +    protected long minEvictableIdleTimeMillis =
  +        GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
  +
  +    public long getMinEvictableIdleTimeMillis() {
  +        return (this.minEvictableIdleTimeMillis);
  +    }
  +
  +    public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
  +        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
  +    }
  +
  +    /**
  +     * The indication of whether objects will be validated by the idle object
  +     * evictor (if any).  If an object fails to validate, it will be dropped
  +     * from the pool.
  +     */
  +    protected boolean testWhileIdle = GenericObjectPool.DEFAULT_TEST_WHILE_IDLE;
  +
  +    public boolean getTestWhileIdle() {
  +        return (this.testWhileIdle);
  +    }
  +
  +    public void setTestWhileIdle(boolean testWhileIdle) {
  +        this.testWhileIdle = testWhileIdle;
  +    }
   
       /**
        * [Read Only] The current number of active connections that have been
  @@ -546,6 +637,13 @@
           connectionPool.setMaxActive(maxActive);
           connectionPool.setMaxIdle(maxIdle);
           connectionPool.setMaxWait(maxWait);
  +        connectionPool.setTestOnBorrow(testOnBorrow);
  +        connectionPool.setTestOnReturn(testOnReturn);
  +        connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
  +        connectionPool.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
  +        connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
  +        connectionPool.setTestWhileIdle(testWhileIdle);
  +        
           if (validationQuery != null) {
               connectionPool.setTestOnBorrow(true);
           }
  
  
  
  1.4       +40 -4     jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java
  
  Index: BasicDataSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicDataSourceFactory.java	21 Jun 2002 21:56:13 -0000	1.3
  +++ BasicDataSourceFactory.java	6 Mar 2003 14:58:42 -0000	1.4
  @@ -156,6 +156,42 @@
                   (Long.parseLong(ra.getContent().toString()));
           }
   
  +        ra = ref.get("testOnBorrow");
  +        if (ra != null) {
  +            dataSource.setTestOnBorrow
  +                (Boolean.valueOf(ra.getContent().toString()).booleanValue());
  +        }
  +
  +        ra = ref.get("testOnReturn");
  +        if (ra != null) {
  +            dataSource.setTestOnReturn
  +                (Boolean.valueOf(ra.getContent().toString()).booleanValue());
  +        }
  +
  +        ra = ref.get("timeBetweenEvictionRunsMillis");
  +        if (ra != null) {
  +            dataSource.setTimeBetweenEvictionRunsMillis
  +                (Long.parseLong(ra.getContent().toString()));
  +        }
  +
  +        ra = ref.get("numTestsPerEvictionRun");
  +        if (ra != null) {
  +            dataSource.setNumTestsPerEvictionRun
  +                (Integer.parseInt(ra.getContent().toString()));
  +        }
  +
  +        ra = ref.get("minEvictableIdleTimeMillis");
  +        if (ra != null) {
  +            dataSource.setMinEvictableIdleTimeMillis
  +                (Long.parseLong(ra.getContent().toString()));
  +        }
  +
  +        ra = ref.get("testWhileIdle");
  +        if (ra != null) {
  +            dataSource.setTestWhileIdle
  +                (Boolean.valueOf(ra.getContent().toString()).booleanValue());
  +        }
  +
           ra = ref.get("password");
           if (ra != null) {
               dataSource.setPassword(ra.getContent().toString());
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message