public abstract class ObjectPool<T> extends Object implements ObjectPoolMBean
| Modifier and Type | Field and Description |
|---|---|
static int |
WHEN_EXHAUSTED_BLOCK |
static int |
WHEN_EXHAUSTED_FAIL
Exhaustion policies
|
static int |
WHEN_EXHAUSTED_RETURN_NULL |
static int |
WHEN_EXHAUSTED_WAIT |
static int |
WHEN_EXHAUSTED_WAIT_RETURN_NULL |
| Constructor and Description |
|---|
ObjectPool(int minSize,
int maxIdle,
int maxSize,
int exhaustionPolicy,
long waitTimeout)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
T |
borrow()
Borrow an object from the pool
|
void |
close()
Close the pool, destroying all objects
|
protected abstract T |
createPoolObject()
Create a new pool object
|
protected abstract void |
destroyPoolObject(T poolObject)
Destroy a pool object
|
static String |
exhaustionPolicyAsString(int exhaustionPolicy) |
int |
getThreadPoolAvailableCount() |
int |
getThreadPoolExhaustionPolicy() |
int |
getThreadPoolMaxIdle() |
int |
getThreadPoolMaxSize() |
int |
getThreadPoolMinSize() |
int |
getThreadPoolPendingWaits() |
int |
getThreadPoolSize() |
long |
getThreadPoolWaitTimeout() |
protected void |
init() |
void |
release(T poolObject)
Return an object to the pool
|
public static final int WHEN_EXHAUSTED_FAIL
public static final int WHEN_EXHAUSTED_BLOCK
public static final int WHEN_EXHAUSTED_WAIT
public static final int WHEN_EXHAUSTED_RETURN_NULL
public static final int WHEN_EXHAUSTED_WAIT_RETURN_NULL
public ObjectPool(int minSize,
int maxIdle,
int maxSize,
int exhaustionPolicy,
long waitTimeout)
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected void init()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic T borrow() throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void release(T poolObject)
poolObject - a pooled object to be returnedpublic void close()
protected abstract T createPoolObject() throws Exception
Exception - on creation errorprotected abstract void destroyPoolObject(T poolObject) throws Exception
poolObject - the object to destroyException - on release errorpublic int getThreadPoolMaxIdle()
getThreadPoolMaxIdle in interface ObjectPoolMBeanpublic int getThreadPoolMinSize()
getThreadPoolMinSize in interface ObjectPoolMBeanpublic int getThreadPoolMaxSize()
getThreadPoolMaxSize in interface ObjectPoolMBeanpublic int getThreadPoolExhaustionPolicy()
getThreadPoolExhaustionPolicy in interface ObjectPoolMBeanpublic long getThreadPoolWaitTimeout()
getThreadPoolWaitTimeout in interface ObjectPoolMBeanpublic int getThreadPoolAvailableCount()
getThreadPoolAvailableCount in interface ObjectPoolMBeanpublic int getThreadPoolPendingWaits()
getThreadPoolPendingWaits in interface ObjectPoolMBeanpublic int getThreadPoolSize()
getThreadPoolSize in interface ObjectPoolMBeanpublic static String exhaustionPolicyAsString(int exhaustionPolicy)
Copyright © 2019. All rights reserved.