QuickServer
v1.4.7

org.quickserver.util.pool
Class BasicObjectPool

java.lang.Object
  extended byorg.quickserver.util.pool.BasicObjectPool
All Implemented Interfaces:
org.apache.commons.pool.ObjectPool, QSObjectPool

public class BasicObjectPool
extends java.lang.Object
implements QSObjectPool

This class will maintain a simple pool of object instances. It internally used a HashSet

Since:
1.3
Author:
Akshathkumar Shetty

Nested Class Summary
static class BasicObjectPool.Config
           
 
Constructor Summary
BasicObjectPool()
           
BasicObjectPool(org.apache.commons.pool.PoolableObjectFactory factory, BasicObjectPool.Config config)
           
 
Method Summary
 void addObject()
           
 java.lang.Object borrowObject()
           
 void clear()
          Clears any objects sitting idle in the pool
 void close()
          Close this pool, and free any resources associated with it.
 java.util.Iterator getAllActiveObjects()
          Returns the iterator of all active objects
 int getNumActive()
          Return the number of instances currently borrowed from my pool
 int getNumIdle()
          Return the number of instances currently idle in my pool
 java.lang.Object getObjectToSynchronize()
           
 void invalidateObject(java.lang.Object obj)
          Invalidates an object from the pool
 void returnObject(java.lang.Object obj)
          Return an instance to my pool
 void setFactory(org.apache.commons.pool.PoolableObjectFactory factory)
          Sets the factory I use to create new instances
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicObjectPool

public BasicObjectPool()

BasicObjectPool

public BasicObjectPool(org.apache.commons.pool.PoolableObjectFactory factory,
                       BasicObjectPool.Config config)
Method Detail

addObject

public void addObject()
               throws java.lang.Exception
Specified by:
addObject in interface org.apache.commons.pool.ObjectPool
Throws:
java.lang.Exception

borrowObject

public java.lang.Object borrowObject()
                              throws java.lang.Exception
Specified by:
borrowObject in interface org.apache.commons.pool.ObjectPool
Throws:
java.lang.Exception

clear

public void clear()
Clears any objects sitting idle in the pool

Specified by:
clear in interface org.apache.commons.pool.ObjectPool

close

public void close()
           throws java.lang.Exception
Close this pool, and free any resources associated with it.

Specified by:
close in interface org.apache.commons.pool.ObjectPool
Throws:
java.lang.Exception

getNumActive

public int getNumActive()
Return the number of instances currently borrowed from my pool

Specified by:
getNumActive in interface org.apache.commons.pool.ObjectPool

getNumIdle

public int getNumIdle()
Return the number of instances currently idle in my pool

Specified by:
getNumIdle in interface org.apache.commons.pool.ObjectPool

invalidateObject

public void invalidateObject(java.lang.Object obj)
                      throws java.lang.Exception
Invalidates an object from the pool

Specified by:
invalidateObject in interface org.apache.commons.pool.ObjectPool
Throws:
java.lang.Exception

returnObject

public void returnObject(java.lang.Object obj)
                  throws java.lang.Exception
Return an instance to my pool

Specified by:
returnObject in interface org.apache.commons.pool.ObjectPool
Throws:
java.lang.Exception

setFactory

public void setFactory(org.apache.commons.pool.PoolableObjectFactory factory)
Sets the factory I use to create new instances

Specified by:
setFactory in interface org.apache.commons.pool.ObjectPool

getAllActiveObjects

public java.util.Iterator getAllActiveObjects()
Returns the iterator of all active objects

Specified by:
getAllActiveObjects in interface QSObjectPool
Since:
1.3.1

getObjectToSynchronize

public java.lang.Object getObjectToSynchronize()
Specified by:
getObjectToSynchronize in interface QSObjectPool

QuickServer
v1.4.7

Copyright © 2003-2006 QuickServer.org