Spring LDAP Framework

org.springframework.ldap.pool.factory
Class PoolingContextSource

java.lang.Object
  extended by org.springframework.ldap.pool.factory.PoolingContextSource
All Implemented Interfaces:
DisposableBean, ContextSource
Direct Known Subclasses:
MutablePoolingContextSource

public class PoolingContextSource
extends Object
implements ContextSource, DisposableBean

A ContextSource implementation that wraps an object pool and another ContextSource. DirContexts are retrieved from the pool which maintains them.

Configuration:

Property Description Required Default
contextSource The ContextSource to get DirContexts from for adding to the pool. Yes null
dirContextValidator The DirContextValidator to use for validating DirContexts. 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

Author:
Eric Dalquist

Field Summary
protected  GenericKeyedObjectPool keyedObjectPool
           
protected  Log logger
          The logger for this class and sub-classes
 
Constructor Summary
PoolingContextSource()
          Creates a new pooling context source, setting up the DirContext object factory and generic keyed object pool.
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
The logger for this class and sub-classes


keyedObjectPool

protected final GenericKeyedObjectPool keyedObjectPool
Constructor Detail

PoolingContextSource

public PoolingContextSource()
Creates a new pooling context source, setting up the DirContext object factory and generic keyed object pool.

Method Detail

getMaxActive

public int getMaxActive()
See Also:
GenericKeyedObjectPool.getMaxActive()

getMaxIdle

public int getMaxIdle()
See Also:
GenericKeyedObjectPool.getMaxIdle()

getMaxTotal

public int getMaxTotal()
See Also:
GenericKeyedObjectPool.getMaxTotal()

getMaxWait

public long getMaxWait()
See Also:
GenericKeyedObjectPool.getMaxWait()

getMinEvictableIdleTimeMillis

public long getMinEvictableIdleTimeMillis()
See Also:
GenericKeyedObjectPool.getMinEvictableIdleTimeMillis()

getMinIdle

public int getMinIdle()
See Also:
GenericKeyedObjectPool.getMinIdle()

getNumActive

public int getNumActive()
See Also:
GenericKeyedObjectPool.getNumActive()

getNumIdle

public int getNumIdle()
See Also:
GenericKeyedObjectPool.getNumIdle()

getNumTestsPerEvictionRun

public int getNumTestsPerEvictionRun()
See Also:
GenericKeyedObjectPool.getNumTestsPerEvictionRun()

getTestOnBorrow

public boolean getTestOnBorrow()
See Also:
GenericKeyedObjectPool.getTestOnBorrow()

getTestOnReturn

public boolean getTestOnReturn()
See Also:
GenericKeyedObjectPool.getTestOnReturn()

getTestWhileIdle

public boolean getTestWhileIdle()
See Also:
GenericKeyedObjectPool.getTestWhileIdle()

getTimeBetweenEvictionRunsMillis

public long getTimeBetweenEvictionRunsMillis()
See Also:
GenericKeyedObjectPool.getTimeBetweenEvictionRunsMillis()

getWhenExhaustedAction

public byte getWhenExhaustedAction()
See Also:
GenericKeyedObjectPool.getWhenExhaustedAction()

setMaxActive

public void setMaxActive(int maxActive)
See Also:
GenericKeyedObjectPool.setMaxActive(int)

setMaxIdle

public void setMaxIdle(int maxIdle)
See Also:
GenericKeyedObjectPool.setMaxIdle(int)

setMaxTotal

public void setMaxTotal(int maxTotal)
See Also:
GenericKeyedObjectPool.setMaxTotal(int)

setMaxWait

public void setMaxWait(long maxWait)
See Also:
GenericKeyedObjectPool.setMaxWait(long)

setMinEvictableIdleTimeMillis

public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
See Also:
GenericKeyedObjectPool.setMinEvictableIdleTimeMillis(long)

setMinIdle

public void setMinIdle(int poolSize)
See Also:
GenericKeyedObjectPool.setMinIdle(int)

setNumTestsPerEvictionRun

public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
See Also:
GenericKeyedObjectPool.setNumTestsPerEvictionRun(int)

setTestOnBorrow

public void setTestOnBorrow(boolean testOnBorrow)
See Also:
GenericKeyedObjectPool.setTestOnBorrow(boolean)

setTestOnReturn

public void setTestOnReturn(boolean testOnReturn)
See Also:
GenericKeyedObjectPool.setTestOnReturn(boolean)

setTestWhileIdle

public void setTestWhileIdle(boolean testWhileIdle)
See Also:
GenericKeyedObjectPool.setTestWhileIdle(boolean)

setTimeBetweenEvictionRunsMillis

public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
See Also:
GenericKeyedObjectPool.setTimeBetweenEvictionRunsMillis(long)

setWhenExhaustedAction

public void setWhenExhaustedAction(byte whenExhaustedAction)
See Also:
GenericKeyedObjectPool.setWhenExhaustedAction(byte)

getContextSource

public ContextSource getContextSource()
Returns:
the contextSource

getDirContextValidator

public DirContextValidator getDirContextValidator()
Returns:
the dirContextValidator

setContextSource

public void setContextSource(ContextSource contextSource)
Parameters:
contextSource - the contextSource to set Required

setDirContextValidator

public void setDirContextValidator(DirContextValidator dirContextValidator)
Parameters:
dirContextValidator - the dirContextValidator to set Required

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

getReadOnlyContext

public DirContext getReadOnlyContext()
                              throws NamingException
Description copied from interface: ContextSource
Gets a read-only DirContext. The returned DirContext must be possible to perform read-only operations on.

Specified by:
getReadOnlyContext in interface ContextSource
Returns:
A DirContext instance, never null.
Throws:
NamingException - if some error occurs creating an DirContext.

getReadWriteContext

public DirContext getReadWriteContext()
                               throws NamingException
Description copied from interface: ContextSource
Gets a read-write DirContext instance.

Specified by:
getReadWriteContext in interface ContextSource
Returns:
A DirContext instance, never null.
Throws:
NamingException - if some error occurs creating an DirContext.

getContext

protected DirContext getContext(DirContextType dirContextType)
Gets a DirContext of the specified type from the keyed object pool.

Parameters:
dirContextType - The type of context to return.
Returns:
A wrapped DirContext of the specified type.
Throws:
DataAccessResourceFailureException - If retrieving the object from the pool throws an exception

getContext

public DirContext getContext(String principal,
                             String credentials)
                      throws NamingException
Description copied from interface: ContextSource
Gets a DirContext instance authenticated using the supplied principal and credentials.

Specified by:
getContext in interface ContextSource
Parameters:
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.
Returns:
an authenticated DirContext instance, never null.
Throws:
NamingException

Spring LDAP Framework

Copyright © 2005-2010 The Spring LDAP Framework. All Rights Reserved.