|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
org.cementj.pool.AbstractResourcePool
public abstract class AbstractResourcePool
Abstract class providing basic resource pool functionality. Provides a default implementation for all ResourcePool interface methods except for createResource(). The easiest way to create a ResourcePool implementation is to extend this class.
Copyright: Delta Vortex Technologies, 2003.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static int |
DEFAULT_POOL_SIZE
Default number of resources allocated to pool |
static long |
DEFAULT_SLEEP_TIME
Default sleep time in milliseconds |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties)
|
|
AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties,
int poolSize)
|
|
AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties,
int poolSize,
long sleepIntervalInMillis)
|
|
| Method Summary | |
|---|---|
void |
closeAll()
Closes all resources in the pool. |
abstract Resource |
createResource(java.util.Properties props)
Defines how a resource is created. |
java.util.Properties |
getCreationProperties()
Gets the used to start resources in the pool. |
static ResourcePool |
getPool(java.lang.String poolName)
Gets the singleton instance of the resource pool. |
java.lang.String |
getPoolName()
Provides name of the resoruce pool. |
int |
getPoolSize()
Gets the number of resources allocated to pool. |
Resource |
getResource()
Obtains resource from the pool. |
long |
getSleepTimeInMillis()
Gets the sleep interval time in milliseconds. |
void |
initPool()
Allocates initial resources for pool. |
void |
logStatus()
Provides pool status information. |
void |
logStatus(Logger out)
Provides pool status information. |
void |
recycleResource(Resource resource)
Validates and puts a resource back in the resource pool. |
void |
run()
Validates idle resources in the pool, replaces them if necessary. |
void |
setCreationProperties(java.util.Properties props)
Sets properties used to create resources for the pool. |
void |
setPoolSize(int size)
Sets the number of resources that should be allocated to the pool. |
void |
setSleepTimeInMillis(long millis)
Sets the sleep time. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long DEFAULT_SLEEP_TIME
public static final int DEFAULT_POOL_SIZE
| Constructor Detail |
|---|
public AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties)
throws ResourceException
ResourceException
public AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties,
int poolSize)
throws ResourceException
ResourceException
public AbstractResourcePool(java.lang.String poolName,
java.util.Properties creationProperties,
int poolSize,
long sleepIntervalInMillis)
throws ResourceException
ResourceException| Method Detail |
|---|
public void initPool()
throws ResourceException
ResourceException
public abstract Resource createResource(java.util.Properties props)
throws ResourceException
ResourcePool
createResource in interface ResourcePoolResourceExceptionpublic void logStatus()
public void logStatus(Logger out)
public void setCreationProperties(java.util.Properties props)
Properties - needed by resource at startup.
public Resource getResource()
throws ResourceException
getResource in interface ResourcePoolResourceExceptionpublic void setSleepTimeInMillis(long millis)
Interval - time in milliseconds.public long getSleepTimeInMillis()
public int getPoolSize()
public void setPoolSize(int size)
sleep - Number of resources allocated to pool.public java.util.Properties getCreationProperties()
public static ResourcePool getPool(java.lang.String poolName)
throws ResourceException
ResourceExceptionpublic void closeAll()
public void recycleResource(Resource resource)
throws ResourceException
recycleResource in interface ResourcePoolresource. -
ResourceExceptionpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
public java.lang.String getPoolName()
throws ResourceException
getPoolName in interface ResourcePoolResourceException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||