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 classPooledConnectionFactory.BuilderclassPooledConnectionFactory.RetryValidationExceptionHandlerValidation 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 ValidationExceptionHandlervalidationExceptionHandlerValidation 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.Builderbuilder()Creates a builder for this class.static PooledConnectionFactory.Builderbuilder(Transport t)Creates a builder for this class.voidclose()Empty this pool, freeing any resources.voidfreeze()Freezes this object, making it immutable.ConnectiongetConnection()Returns a connection from the pool.ConnectionConfiggetConnectionConfig()Returns the connection configuration used to create connections.TransportgetTransport()Returns the ldap transport.ValidationExceptionHandlergetValidationExceptionHandler()Returns the validation exception handler.voidsetConnectionConfig(ConnectionConfig cc)Sets the connection config.voidsetValidationExceptionHandler(ValidationExceptionHandler handler)Sets the validation exception handler.StringtoString()-
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:FreezableFreezes this object, making it immutable.- Specified by:
freezein interfaceFreezable- Overrides:
freezein classAbstractConnectionPool
-
getConnectionConfig
public ConnectionConfig getConnectionConfig()
Description copied from interface:ConnectionFactoryReturns the connection configuration used to create connections.- Specified by:
getConnectionConfigin 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:AbstractConnectionPoolReturns a connection from the pool.- Specified by:
getConnectionin interfaceConnectionFactory- Specified by:
getConnectionin interfaceConnectionPool- Overrides:
getConnectionin 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:AbstractConnectionPoolEmpty this pool, freeing any resources.- Specified by:
closein interfaceConnectionFactory- Specified by:
closein interfaceConnectionPool- Overrides:
closein classAbstractConnectionPool
-
toString
public String toString()
- Overrides:
toStringin 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
-
-