Package org.ldaptive
Class DefaultConnectionFactory
- java.lang.Object
-
- org.ldaptive.DefaultConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
public class DefaultConnectionFactory extends Object implements ConnectionFactory
Creates connections for performing ldap operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DefaultConnectionFactory.DefaultConnection
Default implementation for managing a connection to an LDAP.
-
Field Summary
Fields Modifier and Type Field Description private ConnectionConfig
config
Connection configuration used by this factory.protected static Provider<?>
DEFAULT_PROVIDER
Static reference to the default ldap provider.private Provider<?>
provider
Provider used by this factory.static String
PROVIDER
Ldap provider class name.
-
Constructor Summary
Constructors Constructor Description DefaultConnectionFactory()
Default constructor.DefaultConnectionFactory(String ldapUrl)
Creates a new default connection factory.DefaultConnectionFactory(ConnectionConfig cc)
Creates a new default connection factory.DefaultConnectionFactory(ConnectionConfig cc, Provider<?> p)
Creates a new default connection factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Connection
getConnection()
Creates a new connection.static Connection
getConnection(String ldapUrl)
Creates a new connection.static Connection
getConnection(ConnectionConfig cc)
Creates a new connection.ConnectionConfig
getConnectionConfig()
Returns the connection config.static Provider<?>
getDefaultProvider()
ThePROVIDER
property is checked and that class is loaded if provided.Provider<?>
getProvider()
Returns the ldap provider.void
setConnectionConfig(ConnectionConfig cc)
Sets the connection config.void
setProvider(Provider<?> p)
Sets the ldap provider.String
toString()
-
-
-
Field Detail
-
PROVIDER
public static final String PROVIDER
Ldap provider class name.- See Also:
- Constant Field Values
-
DEFAULT_PROVIDER
protected static final Provider<?> DEFAULT_PROVIDER
Static reference to the default ldap provider.
-
provider
private Provider<?> provider
Provider used by this factory.
-
config
private ConnectionConfig config
Connection configuration used by this factory.
-
-
Constructor Detail
-
DefaultConnectionFactory
public DefaultConnectionFactory()
Default constructor.
-
DefaultConnectionFactory
public DefaultConnectionFactory(String ldapUrl)
Creates a new default connection factory.- Parameters:
ldapUrl
- to connect to
-
DefaultConnectionFactory
public DefaultConnectionFactory(ConnectionConfig cc)
Creates a new default connection factory.- Parameters:
cc
- connection configuration
-
DefaultConnectionFactory
public DefaultConnectionFactory(ConnectionConfig cc, Provider<?> p)
Creates a new default connection factory.- Parameters:
cc
- connection configurationp
- provider
-
-
Method Detail
-
getConnectionConfig
public ConnectionConfig getConnectionConfig()
Returns the connection config.- Returns:
- connection config
-
setConnectionConfig
public void setConnectionConfig(ConnectionConfig cc)
Sets the connection config. Once invoked the supplied connection config is made immutable. SeeAbstractConfig.makeImmutable()
.- Parameters:
cc
- connection config
-
getProvider
public Provider<?> getProvider()
Returns the ldap provider.- Returns:
- ldap provider
-
setProvider
public void setProvider(Provider<?> p)
Sets the ldap provider.- Parameters:
p
- ldap provider to set
-
getConnection
public Connection getConnection()
Creates a new connection. Connections returned from this method must be opened before they can perform ldap operations.- Specified by:
getConnection
in interfaceConnectionFactory
- Returns:
- connection
-
getConnection
public static Connection getConnection(String ldapUrl)
Creates a new connection. Connections returned from this method must be opened before they can be used.- Parameters:
ldapUrl
- to connect to- Returns:
- connection
-
getConnection
public static Connection getConnection(ConnectionConfig cc)
Creates a new connection. Connections returned from this method must be opened before they can be used.- Parameters:
cc
- connection configuration- Returns:
- connection
-
getDefaultProvider
public static Provider<?> getDefaultProvider()
ThePROVIDER
property is checked and that class is loaded if provided. Otherwise the JNDI provider is returned.- Returns:
- default provider
-
-