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/pool/src/test/org/apache/commons/pool TestBaseObjectPool.java
Date Thu, 24 Apr 2003 01:22:37 GMT
rwaldhoff    2003/04/23 18:22:37

  Modified:    pool/src/java/org/apache/commons/pool ObjectPool.java
                        BaseObjectPool.java
               pool/src/java/org/apache/commons/pool/impl
                        SoftReferenceObjectPool.java StackObjectPool.java
               pool/src/test/org/apache/commons/pool
                        TestBaseObjectPool.java
  Log:
  add optional addObject() to StackObjectPool, SoftReferenceObjectPool, BaseObjectPool and
ObjectPool
  
  Revision  Changes    Path
  1.8       +12 -4     jakarta-commons/pool/src/java/org/apache/commons/pool/ObjectPool.java
  
  Index: ObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/ObjectPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ObjectPool.java	30 Oct 2002 22:54:41 -0000	1.7
  +++ ObjectPool.java	24 Apr 2003 01:22:36 -0000	1.8
  @@ -133,6 +133,14 @@
       void invalidateObject(Object obj) throws Exception;
   
       /**
  +     * Create an object using my {@link #setFactory factory} or other
  +     * implementation dependent mechanism, and place it into the pool.
  +     * addObject() is useful for "pre-loading" a pool with idle objects.
  +     * (Optional operation).
  +     */
  +    void addObject() throws Exception;
  +
  +    /**
        * Return the number of instances
        * currently idle in my pool (optional operation).  
        * This may be considered an approximation of the number
  
  
  
  1.10      +11 -4     jakarta-commons/pool/src/java/org/apache/commons/pool/BaseObjectPool.java
  
  Index: BaseObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/BaseObjectPool.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BaseObjectPool.java	7 Mar 2003 20:28:36 -0000	1.9
  +++ BaseObjectPool.java	24 Apr 2003 01:22:36 -0000	1.10
  @@ -95,6 +95,13 @@
           throw new UnsupportedOperationException();
       }
   
  +    /**
  +     * Not supported in this base implementation.
  +     */
  +    public void addObject() throws Exception, UnsupportedOperationException {
  +        throw new UnsupportedOperationException();
  +    }
  +
       public void close() throws Exception {
           assertOpen();
           closed = true;
  
  
  
  1.9       +16 -4     jakarta-commons/pool/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
  
  Index: SoftReferenceObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SoftReferenceObjectPool.java	7 Mar 2003 15:18:20 -0000	1.8
  +++ SoftReferenceObjectPool.java	24 Apr 2003 01:22:36 -0000	1.9
  @@ -162,6 +162,18 @@
           notifyAll(); // _numActive has changed
       }
   
  +    /**
  +     * Create an object, and place it into the pool.
  +     * addObject() is useful for "pre-loading" a pool with idle objects.
  +     */
  +    public void addObject() throws Exception {
  +        Object obj = _factory.makeObject();
  +        synchronized(this) {
  +            _numActive++;   // A little slimy - must do this because returnObject decrements
it.
  +            this.returnObject(obj);
  +        }
  +    }
  +
       /** Returns an approximation not less than the of the number of idle instances in the
pool. */
       public int getNumIdle() {
           return _pool.size();
  
  
  
  1.12      +16 -4     jakarta-commons/pool/src/java/org/apache/commons/pool/impl/StackObjectPool.java
  
  Index: StackObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/StackObjectPool.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StackObjectPool.java	13 Mar 2003 18:40:09 -0000	1.11
  +++ StackObjectPool.java	24 Apr 2003 01:22:36 -0000	1.12
  @@ -260,6 +260,18 @@
           super.close();
       }
   
  +    /**
  +     * Create an object, and place it into the pool.
  +     * addObject() is useful for "pre-loading" a pool with idle objects.
  +     */
  +    public void addObject() throws Exception {
  +        Object obj = _factory.makeObject();
  +        synchronized(this) {
  +            _numActive++;   // A little slimy - must do this because returnObject decrements
it.
  +            this.returnObject(obj);
  +        }
  +    }
  +
       synchronized public void setFactory(PoolableObjectFactory factory) throws IllegalStateException
{
           assertOpen();
           if(0 < getNumActive()) {
  
  
  
  1.2       +11 -4     jakarta-commons/pool/src/test/org/apache/commons/pool/TestBaseObjectPool.java
  
  Index: TestBaseObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/test/org/apache/commons/pool/TestBaseObjectPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestBaseObjectPool.java	22 Apr 2003 23:14:52 -0000	1.1
  +++ TestBaseObjectPool.java	24 Apr 2003 01:22:37 -0000	1.2
  @@ -111,6 +111,13 @@
           }
   
           try {
  +            pool.addObject();
  +            fail("Expected UnsupportedOperationException");
  +        } catch(UnsupportedOperationException e) {
  +            // expected
  +        }
  +
  +        try {
               pool.setFactory(null);
               fail("Expected UnsupportedOperationException");
           } catch(UnsupportedOperationException e) {
  
  
  

---------------------------------------------------------------------
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