Package org.ldaptive
Class PooledConnectionFactory
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.pool.AbstractConnectionPool
-
- org.ldaptive.pool.BlockingConnectionPool
-
- org.ldaptive.PooledConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
,Freezable
,ConnectionPool
public final class PooledConnectionFactory extends BlockingConnectionPool implements ConnectionFactory
Creates connections for performing ldap operations and manages those connections as a pool.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PooledConnectionFactory.Builder
class
PooledConnectionFactory.RetryValidationExceptionHandler
Validation exception handler that attempts to retrieve another connection.-
Nested classes/interfaces inherited from class org.ldaptive.pool.AbstractConnectionPool
AbstractConnectionPool.DefaultPooledConnectionProxy
-
-
Field Summary
Fields Modifier and Type Field Description private ValidationExceptionHandler
validationExceptionHandler
Validation exception handler.-
Fields inherited from class org.ldaptive.pool.AbstractConnectionPool
active, available, checkOutLock, DEFAULT_MAX_POOL_SIZE, DEFAULT_MIN_POOL_SIZE, logger, poolLock, poolNotEmpty
-
-
Constructor Summary
Constructors Constructor Description PooledConnectionFactory()
Default constructor.PooledConnectionFactory(String ldapUrl)
Creates a new pooled connection factory.PooledConnectionFactory(String ldapUrl, Transport t)
Creates a new pooled connection factory.PooledConnectionFactory(ConnectionConfig cc)
Creates a new pooled connection factory.PooledConnectionFactory(ConnectionConfig cc, Transport t)
Creates a new pooled connection factory.PooledConnectionFactory(Transport t)
Creates a new pooled connection factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PooledConnectionFactory.Builder
builder()
Creates a builder for this class.static PooledConnectionFactory.Builder
builder(Transport t)
Creates a builder for this class.void
close()
Empty this pool, freeing any resources.void
freeze()
Freezes this object, making it immutable.Connection
getConnection()
Returns a connection from the pool.ConnectionConfig
getConnectionConfig()
Returns the connection configuration used to create connections.Transport
getTransport()
Returns the ldap transport.ValidationExceptionHandler
getValidationExceptionHandler()
Returns the validation exception handler.void
setConnectionConfig(ConnectionConfig cc)
Sets the connection config.void
setValidationExceptionHandler(ValidationExceptionHandler handler)
Sets the validation exception handler.String
toString()
-
Methods inherited from class org.ldaptive.pool.BlockingConnectionPool
blockAvailableConnection, getBlockWaitTime, putConnection, retrieveAvailableConnection, setBlockWaitTime
-
Methods inherited from class org.ldaptive.pool.AbstractConnectionPool
activateAndValidateConnection, activeCount, availableCount, createActiveConnection, createAvailableConnection, createAvailableConnections, createConnection, createConnectionProxy, getActivator, getConnectOnCreate, getDefaultConnectionFactory, getFailFastInitialize, getMaxPoolSize, getMinPoolSize, getName, getPassivator, getPooledConnectionStatistics, getPruneStrategy, getQueueType, getValidator, grow, initialize, isInitialized, isValidateOnCheckIn, isValidateOnCheckOut, isValidatePeriodically, passivateAndValidateConnection, prune, removeActiveConnection, removeAvailableAndActiveConnection, removeAvailableConnection, retrieveConnectionProxy, setActivator, setConnectOnCreate, setDefaultConnectionFactory, setFailFastInitialize, setMaxPoolSize, setMinPoolSize, setName, setPassivator, setPruneStrategy, setQueueType, setValidateOnCheckIn, setValidateOnCheckOut, setValidatePeriodically, setValidator, throwIfNotInitialized, validate
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
validationExceptionHandler
private ValidationExceptionHandler validationExceptionHandler
Validation exception handler. Default implementation retries once.
-
-
Constructor Detail
-
PooledConnectionFactory
public PooledConnectionFactory()
Default constructor.
-
PooledConnectionFactory
public PooledConnectionFactory(Transport t)
Creates a new pooled connection factory.- Parameters:
t
- transport
-
PooledConnectionFactory
public PooledConnectionFactory(String ldapUrl)
Creates a new pooled connection factory.- Parameters:
ldapUrl
- to connect to
-
PooledConnectionFactory
public PooledConnectionFactory(String ldapUrl, Transport t)
Creates a new pooled connection factory.- Parameters:
ldapUrl
- to connect tot
- transport
-
PooledConnectionFactory
public PooledConnectionFactory(ConnectionConfig cc)
Creates a new pooled connection factory.- Parameters:
cc
- connection configuration
-
PooledConnectionFactory
public PooledConnectionFactory(ConnectionConfig cc, Transport t)
Creates a new pooled connection factory.- Parameters:
cc
- connection configurationt
- transport
-
-
Method Detail
-
freeze
public void freeze()
Description copied from interface:Freezable
Freezes this object, making it immutable.- Specified by:
freeze
in interfaceFreezable
- Overrides:
freeze
in classAbstractConnectionPool
-
getConnectionConfig
public ConnectionConfig getConnectionConfig()
Description copied from interface:ConnectionFactory
Returns the connection configuration used to create connections.- Specified by:
getConnectionConfig
in interfaceConnectionFactory
- Returns:
- connection config
-
setConnectionConfig
public void setConnectionConfig(ConnectionConfig cc)
Sets the connection config. Once invoked the supplied connection config is made immutable. SeeConnectionConfig.freeze()
.- Parameters:
cc
- connection config
-
getValidationExceptionHandler
public ValidationExceptionHandler getValidationExceptionHandler()
Returns the validation exception handler.- Returns:
- validation exception handler
-
setValidationExceptionHandler
public void setValidationExceptionHandler(ValidationExceptionHandler handler)
Sets the validation exception handler.- Parameters:
handler
- validation exception handler
-
getTransport
public Transport getTransport()
Returns the ldap transport.- Returns:
- ldap transport
-
getConnection
public Connection getConnection() throws PoolException
Description copied from class:AbstractConnectionPool
Returns a connection from the pool.- Specified by:
getConnection
in interfaceConnectionFactory
- Specified by:
getConnection
in interfaceConnectionPool
- Overrides:
getConnection
in classBlockingConnectionPool
- Returns:
- connection
- Throws:
PoolException
- if this operation failsBlockingTimeoutException
- if this pool is configured with a block time and it occurs
-
close
public void close()
Description copied from class:AbstractConnectionPool
Empty this pool, freeing any resources.- Specified by:
close
in interfaceConnectionFactory
- Specified by:
close
in interfaceConnectionPool
- Overrides:
close
in classAbstractConnectionPool
-
toString
public String toString()
- Overrides:
toString
in classBlockingConnectionPool
-
builder
public static PooledConnectionFactory.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
builder
public static PooledConnectionFactory.Builder builder(Transport t)
Creates a builder for this class.- Parameters:
t
- transport- Returns:
- new builder
-
-