public class PoolingContextSource extends Object implements ContextSource, org.springframework.beans.factory.DisposableBean
ContextSource
implementation that wraps an object pool and another
ContextSource
. DirContext
s are retrieved from the pool which
maintains them.
Property | Description | Required | Default |
---|---|---|---|
contextSource |
The ContextSource to get DirContext s from for adding to the
pool. |
Yes | null |
dirContextValidator |
The DirContextValidator to use for validating DirContext s.
Required if any of the test/validate options are enabled. |
No | null |
minIdle | GenericKeyedObjectPool.setMinIdle(int) |
No | 0 |
maxIdle | GenericKeyedObjectPool.setMaxIdle(int) |
No | 8 |
maxActive | GenericKeyedObjectPool.setMaxActive(int) |
No | 8 |
maxTotal | GenericKeyedObjectPool.setMaxTotal(int) |
No | -1 |
maxWait | GenericKeyedObjectPool.setMaxWait(long) |
No | -1L |
whenExhaustedAction | GenericKeyedObjectPool.setWhenExhaustedAction(byte) |
No | GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK |
testOnBorrow | GenericKeyedObjectPool.setTestOnBorrow(boolean) |
No | false |
testOnReturn | GenericKeyedObjectPool.setTestOnReturn(boolean) |
No | false |
testWhileIdle | GenericKeyedObjectPool.setTestWhileIdle(boolean) |
No | false |
timeBetweenEvictionRunsMillis |
GenericKeyedObjectPool.setTimeBetweenEvictionRunsMillis(long) |
No | -1L |
minEvictableIdleTimeMillis |
GenericKeyedObjectPool.setMinEvictableIdleTimeMillis(long) |
No | 1000L * 60L * 30L |
numTestsPerEvictionRun |
GenericKeyedObjectPool.setNumTestsPerEvictionRun(int) |
No | 3 |
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.pool.impl.GenericKeyedObjectPool |
keyedObjectPool |
protected org.apache.commons.logging.Log |
logger
The logger for this class and sub-classes
|
Constructor and Description |
---|
PoolingContextSource()
Creates a new pooling context source, setting up the DirContext object
factory and generic keyed object pool.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
protected DirContext |
getContext(DirContextType dirContextType)
Gets a DirContext of the specified type from the keyed object pool.
|
DirContext |
getContext(String principal,
String credentials)
Gets a
DirContext instance authenticated using the supplied
principal and credentials. |
ContextSource |
getContextSource() |
DirContextValidator |
getDirContextValidator() |
int |
getMaxActive() |
int |
getMaxIdle() |
int |
getMaxTotal() |
long |
getMaxWait() |
long |
getMinEvictableIdleTimeMillis() |
int |
getMinIdle() |
int |
getNumActive() |
int |
getNumIdle() |
int |
getNumTestsPerEvictionRun() |
DirContext |
getReadOnlyContext()
Gets a read-only
DirContext . |
DirContext |
getReadWriteContext()
Gets a read-write
DirContext instance. |
boolean |
getTestOnBorrow() |
boolean |
getTestOnReturn() |
boolean |
getTestWhileIdle() |
long |
getTimeBetweenEvictionRunsMillis() |
byte |
getWhenExhaustedAction() |
void |
setContextSource(ContextSource contextSource) |
void |
setDirContextValidator(DirContextValidator dirContextValidator) |
void |
setMaxActive(int maxActive) |
void |
setMaxIdle(int maxIdle) |
void |
setMaxTotal(int maxTotal) |
void |
setMaxWait(long maxWait) |
void |
setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) |
void |
setMinIdle(int poolSize) |
void |
setNumTestsPerEvictionRun(int numTestsPerEvictionRun) |
void |
setTestOnBorrow(boolean testOnBorrow) |
void |
setTestOnReturn(boolean testOnReturn) |
void |
setTestWhileIdle(boolean testWhileIdle) |
void |
setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) |
void |
setWhenExhaustedAction(byte whenExhaustedAction) |
protected final org.apache.commons.logging.Log logger
protected final org.apache.commons.pool.impl.GenericKeyedObjectPool keyedObjectPool
public PoolingContextSource()
public int getMaxActive()
GenericKeyedObjectPool.getMaxActive()
public int getMaxIdle()
GenericKeyedObjectPool.getMaxIdle()
public int getMaxTotal()
GenericKeyedObjectPool.getMaxTotal()
public long getMaxWait()
GenericKeyedObjectPool.getMaxWait()
public long getMinEvictableIdleTimeMillis()
GenericKeyedObjectPool.getMinEvictableIdleTimeMillis()
public int getMinIdle()
GenericKeyedObjectPool.getMinIdle()
public int getNumActive()
GenericKeyedObjectPool.getNumActive()
public int getNumIdle()
GenericKeyedObjectPool.getNumIdle()
public int getNumTestsPerEvictionRun()
GenericKeyedObjectPool.getNumTestsPerEvictionRun()
public boolean getTestOnBorrow()
GenericKeyedObjectPool.getTestOnBorrow()
public boolean getTestOnReturn()
GenericKeyedObjectPool.getTestOnReturn()
public boolean getTestWhileIdle()
GenericKeyedObjectPool.getTestWhileIdle()
public long getTimeBetweenEvictionRunsMillis()
GenericKeyedObjectPool.getTimeBetweenEvictionRunsMillis()
public byte getWhenExhaustedAction()
GenericKeyedObjectPool.getWhenExhaustedAction()
public void setMaxActive(int maxActive)
GenericKeyedObjectPool.setMaxActive(int)
public void setMaxIdle(int maxIdle)
GenericKeyedObjectPool.setMaxIdle(int)
public void setMaxTotal(int maxTotal)
GenericKeyedObjectPool.setMaxTotal(int)
public void setMaxWait(long maxWait)
GenericKeyedObjectPool.setMaxWait(long)
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
GenericKeyedObjectPool.setMinEvictableIdleTimeMillis(long)
public void setMinIdle(int poolSize)
GenericKeyedObjectPool.setMinIdle(int)
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
GenericKeyedObjectPool.setNumTestsPerEvictionRun(int)
public void setTestOnBorrow(boolean testOnBorrow)
GenericKeyedObjectPool.setTestOnBorrow(boolean)
public void setTestOnReturn(boolean testOnReturn)
GenericKeyedObjectPool.setTestOnReturn(boolean)
public void setTestWhileIdle(boolean testWhileIdle)
GenericKeyedObjectPool.setTestWhileIdle(boolean)
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
GenericKeyedObjectPool.setTimeBetweenEvictionRunsMillis(long)
public void setWhenExhaustedAction(byte whenExhaustedAction)
GenericKeyedObjectPool.setWhenExhaustedAction(byte)
public ContextSource getContextSource()
public DirContextValidator getDirContextValidator()
public void setContextSource(ContextSource contextSource)
contextSource
- the contextSource to set
Requiredpublic void setDirContextValidator(DirContextValidator dirContextValidator)
dirContextValidator
- the dirContextValidator to set
Requiredpublic void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
public DirContext getReadOnlyContext() throws NamingException
ContextSource
DirContext
. The returned
DirContext
must be possible to perform read-only operations
on.getReadOnlyContext
in interface ContextSource
NamingException
- if some error occurs creating an DirContext.public DirContext getReadWriteContext() throws NamingException
ContextSource
DirContext
instance.getReadWriteContext
in interface ContextSource
DirContext
instance, never null
.NamingException
- if some error occurs creating an
DirContext
.protected DirContext getContext(DirContextType dirContextType)
dirContextType
- The type of context to return.org.springframework.dao.DataAccessResourceFailureException
- If retrieving the object from
the pool throws an exceptionpublic DirContext getContext(String principal, String credentials) throws NamingException
ContextSource
DirContext
instance authenticated using the supplied
principal and credentials.getContext
in interface ContextSource
principal
- The principal (typically a distinguished name of a user
in the LDAP tree) to use for authentication.credentials
- The credentials to use for authentication.DirContext
instance, never
null
.NamingException
Copyright © 2005–2016 The Spring LDAP Framework. All rights reserved.