Package org.ldaptive
Class SingleConnectionFactory
- java.lang.Object
-
- org.ldaptive.DefaultConnectionFactory
-
- org.ldaptive.SingleConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
public class SingleConnectionFactory extends DefaultConnectionFactory
Creates a single connection which is proxied for LDAP operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SingleConnectionFactory.Builder
protected static class
SingleConnectionFactory.ConnectionProxy
Contains the connection used by this factory.
-
Field Summary
Fields Modifier and Type Field Description private Connection
connection
The connection used by this factory.private boolean
failFastInitialize
Whetherinitialize()
should throw if the connection cannot be opened.private boolean
initialized
Whetherinitialize()
has been successfully invoked.private ExecutorService
initializeExecutor
Executor for schedulinginitialize()
.private boolean
nonBlockingInitialize
Whetherinitialize()
should occur on a separate thread.private Connection
proxy
The proxy used by this factory.-
Fields inherited from class org.ldaptive.DefaultConnectionFactory
logger
-
-
Constructor Summary
Constructors Constructor Description SingleConnectionFactory()
Default constructor.SingleConnectionFactory(String ldapUrl)
Creates a new single connection factory.SingleConnectionFactory(String ldapUrl, Transport t)
Creates a new single connection factory.SingleConnectionFactory(ConnectionConfig cc)
Creates a new single connection factory.SingleConnectionFactory(ConnectionConfig cc, Transport t)
Creates a new single connection factory.SingleConnectionFactory(Transport t)
Creates a new single connection factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SingleConnectionFactory.Builder
builder()
Creates a builder for this class.static SingleConnectionFactory.Builder
builder(Transport t)
Creates a builder for this class.void
close()
Free any resources associated with this factory.Connection
getConnection()
Creates a new connection.boolean
getFailFastInitialize()
Returns whetherinitialize()
should throw if the connection cannot be opened.boolean
getNonBlockingInitialize()
Returns whetherinitialize()
should execute on a separate thread.void
initialize()
Prepares this factory for use.private void
initializeInternal()
Attempts to open the connection and establish the proxy.boolean
isInitialized()
Returns whether this factory has been initialized.void
setFailFastInitialize(boolean b)
Sets whetherinitialize()
should throw if the connection cannot be opened.void
setNonBlockingInitialize(boolean b)
Sets whetherinitialize()
should execute on a separate thread.String
toString()
-
Methods inherited from class org.ldaptive.DefaultConnectionFactory
getConnectionConfig, getTransport, setConnectionConfig
-
-
-
-
Field Detail
-
connection
private Connection connection
The connection used by this factory.
-
proxy
private Connection proxy
The proxy used by this factory.
-
initialized
private boolean initialized
Whetherinitialize()
has been successfully invoked.
-
failFastInitialize
private boolean failFastInitialize
Whetherinitialize()
should throw if the connection cannot be opened.
-
nonBlockingInitialize
private boolean nonBlockingInitialize
Whetherinitialize()
should occur on a separate thread.
-
initializeExecutor
private ExecutorService initializeExecutor
Executor for schedulinginitialize()
.
-
-
Constructor Detail
-
SingleConnectionFactory
public SingleConnectionFactory()
Default constructor.
-
SingleConnectionFactory
public SingleConnectionFactory(Transport t)
Creates a new single connection factory.- Parameters:
t
- transport
-
SingleConnectionFactory
public SingleConnectionFactory(String ldapUrl)
Creates a new single connection factory.- Parameters:
ldapUrl
- to connect to
-
SingleConnectionFactory
public SingleConnectionFactory(String ldapUrl, Transport t)
Creates a new single connection factory.- Parameters:
ldapUrl
- to connect tot
- transport
-
SingleConnectionFactory
public SingleConnectionFactory(ConnectionConfig cc)
Creates a new single connection factory.- Parameters:
cc
- connection configuration
-
SingleConnectionFactory
public SingleConnectionFactory(ConnectionConfig cc, Transport t)
Creates a new single connection factory.- Parameters:
cc
- connection configurationt
- transport
-
-
Method Detail
-
getFailFastInitialize
public boolean getFailFastInitialize()
Returns whetherinitialize()
should throw if the connection cannot be opened.- Returns:
- whether
initialize()
should throw
-
setFailFastInitialize
public void setFailFastInitialize(boolean b)
Sets whetherinitialize()
should throw if the connection cannot be opened.- Parameters:
b
- whetherinitialize()
should throw
-
getNonBlockingInitialize
public boolean getNonBlockingInitialize()
Returns whetherinitialize()
should execute on a separate thread.- Returns:
- whether
initialize()
should block
-
setNonBlockingInitialize
public void setNonBlockingInitialize(boolean b)
Sets whetherinitialize()
should execute on a separate thread.- Parameters:
b
- whetherinitialize()
should block
-
isInitialized
public boolean isInitialized()
Returns whether this factory has been initialized.- Returns:
- whether this factory has been initialized
-
initialize
public void initialize() throws LdapException
Prepares this factory for use.- Throws:
LdapException
- if the connection cannot be opened
-
initializeInternal
private void initializeInternal() throws LdapException
Attempts to open the connection and establish the proxy.- Throws:
LdapException
- ifConnection.open()
fails andfailFastInitialize
is true
-
getConnection
public Connection getConnection()
Description copied from class:DefaultConnectionFactory
Creates a new connection. Connections returned from this method must be opened before they can perform ldap operations.- Specified by:
getConnection
in interfaceConnectionFactory
- Overrides:
getConnection
in classDefaultConnectionFactory
- Returns:
- connection
-
close
public void close()
Description copied from interface:ConnectionFactory
Free any resources associated with this factory.- Specified by:
close
in interfaceConnectionFactory
- Overrides:
close
in classDefaultConnectionFactory
-
toString
public String toString()
- Overrides:
toString
in classDefaultConnectionFactory
-
builder
public static SingleConnectionFactory.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
builder
public static SingleConnectionFactory.Builder builder(Transport t)
Creates a builder for this class.- Parameters:
t
- transport- Returns:
- new builder
-
-