public class DefaultConfigurableKeyedObjectPool extends Object implements ConfigurableKeyedObjectPool
ConfigurableKeyedObjectPool
as a delegate of a KeyedPoolableObjectFactory
instance.WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW
Constructor and Description |
---|
DefaultConfigurableKeyedObjectPool() |
Modifier and Type | Method and Description |
---|---|
void |
addObject(Object key) |
Object |
borrowObject(Object key) |
void |
clear()
Clears the pool, removing all pooled instances.
|
void |
clear(Object key) |
void |
close() |
int |
getMaxActive()
Returns the cap on the number of active instances per key.
|
int |
getMaxIdle()
Returns the cap on the number of "idle" instances per key.
|
int |
getMaxTotal()
Returns the overall maximum number of objects (across pools) that can
exist at one time.
|
long |
getMaxWait()
Returns the maximum amount of time (in milliseconds) the
KeyedObjectPool.borrowObject(K) method should block before throwing
an exception when the pool is exhausted and the
"when exhausted" action is
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK . |
int |
getNumActive() |
int |
getNumActive(Object key) |
int |
getNumIdle() |
int |
getNumIdle(Object key) |
byte |
getWhenExhaustedAction()
Returns the action to take when the
KeyedObjectPool.borrowObject(K) method
is invoked when the pool is exhausted. |
void |
invalidateObject(Object key,
Object obj) |
void |
returnObject(Object key,
Object obj) |
void |
setFactory(org.apache.commons.pool.KeyedPoolableObjectFactory factory) |
void |
setMaxActive(int maxActive)
Sets the cap on the number of active instances per key.
|
void |
setMaxIdle(int maxIdle)
Sets the cap on the number of "idle" instances in the pool.
|
void |
setMaxTotal(int maxTotal)
Sets the cap on the total number of instances from all pools combined.
|
void |
setMaxWait(long maxWait)
Sets the maximum amount of time (in milliseconds) the
KeyedObjectPool.borrowObject(K) method should block before throwing
an exception when the pool is exhausted and the
"when exhausted" action is
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK . |
void |
setWhenExhaustedAction(byte whenExhaustedAction)
Sets the action to take when the
KeyedObjectPool.borrowObject(K) method
is invoked when the pool is exhausted. |
public Object borrowObject(Object key) throws Exception, NoSuchElementException, IllegalStateException
borrowObject
in interface org.apache.commons.pool.KeyedObjectPool
Exception
NoSuchElementException
IllegalStateException
public void returnObject(Object key, Object obj) throws Exception
returnObject
in interface org.apache.commons.pool.KeyedObjectPool
Exception
public void invalidateObject(Object key, Object obj) throws Exception
invalidateObject
in interface org.apache.commons.pool.KeyedObjectPool
Exception
public void addObject(Object key) throws Exception, IllegalStateException, UnsupportedOperationException
addObject
in interface org.apache.commons.pool.KeyedObjectPool
Exception
IllegalStateException
UnsupportedOperationException
public int getNumIdle(Object key) throws UnsupportedOperationException
getNumIdle
in interface org.apache.commons.pool.KeyedObjectPool
UnsupportedOperationException
public int getNumActive(Object key) throws UnsupportedOperationException
getNumActive
in interface org.apache.commons.pool.KeyedObjectPool
UnsupportedOperationException
public int getNumIdle() throws UnsupportedOperationException
getNumIdle
in interface org.apache.commons.pool.KeyedObjectPool
UnsupportedOperationException
public int getNumActive() throws UnsupportedOperationException
getNumActive
in interface org.apache.commons.pool.KeyedObjectPool
UnsupportedOperationException
public void clear()
ConfigurableKeyedObjectPool
clear
in interface org.apache.commons.pool.KeyedObjectPool
clear
in interface ConfigurableKeyedObjectPool
public void clear(Object key) throws Exception, UnsupportedOperationException
clear
in interface org.apache.commons.pool.KeyedObjectPool
Exception
UnsupportedOperationException
public void close() throws Exception
close
in interface org.apache.commons.pool.KeyedObjectPool
Exception
public void setFactory(org.apache.commons.pool.KeyedPoolableObjectFactory factory) throws IllegalStateException, UnsupportedOperationException
setFactory
in interface org.apache.commons.pool.KeyedObjectPool
IllegalStateException
UnsupportedOperationException
public int getMaxActive()
ConfigurableKeyedObjectPool
getMaxActive
in interface ConfigurableKeyedObjectPool
public int getMaxTotal()
ConfigurableKeyedObjectPool
getMaxTotal
in interface ConfigurableKeyedObjectPool
public void setMaxWait(long maxWait)
ConfigurableKeyedObjectPool
KeyedObjectPool.borrowObject(K)
method should block before throwing
an exception when the pool is exhausted and the
"when exhausted" action
is
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK
.
When less than or equal to 0, the KeyedObjectPool.borrowObject(K)
method
may block indefinitely.setMaxWait
in interface ConfigurableKeyedObjectPool
maxWait
- the maximum number of milliseconds borrowObject will block or negative for indefinitely.public void setMaxActive(int maxActive)
ConfigurableKeyedObjectPool
setMaxActive
in interface ConfigurableKeyedObjectPool
maxActive
- The cap on the number of active instances per key.
Use a negative value for no limit.public void setMaxIdle(int maxIdle)
ConfigurableKeyedObjectPool
setMaxIdle
in interface ConfigurableKeyedObjectPool
maxIdle
- the maximum number of "idle" instances that can be held
in a given keyed pool. Use a negative value for no limit.public void setMaxTotal(int maxTotal)
ConfigurableKeyedObjectPool
setMaxTotal
in interface ConfigurableKeyedObjectPool
maxTotal
- The cap on the total number of instances across pools.
Use a negative value for no limit.public int getMaxIdle()
ConfigurableKeyedObjectPool
getMaxIdle
in interface ConfigurableKeyedObjectPool
public void setWhenExhaustedAction(byte whenExhaustedAction)
ConfigurableKeyedObjectPool
KeyedObjectPool.borrowObject(K)
method
is invoked when the pool is exhausted.setWhenExhaustedAction
in interface ConfigurableKeyedObjectPool
whenExhaustedAction
- the action code, which must be one of
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK
, ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_FAIL
,
or ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_GROW
public byte getWhenExhaustedAction()
ConfigurableKeyedObjectPool
KeyedObjectPool.borrowObject(K)
method
is invoked when the pool is exhausted.getWhenExhaustedAction
in interface ConfigurableKeyedObjectPool
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK
,
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_FAIL
or ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_GROW
public long getMaxWait()
ConfigurableKeyedObjectPool
KeyedObjectPool.borrowObject(K)
method should block before throwing
an exception when the pool is exhausted and the
"when exhausted" action
is
ConfigurableKeyedObjectPool.WHEN_EXHAUSTED_BLOCK
.
When less than or equal to 0, the KeyedObjectPool.borrowObject(K)
method
may block indefinitely.getMaxWait
in interface ConfigurableKeyedObjectPool
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.