Package org.ldaptive
Class AbstractConnectionStrategy
- java.lang.Object
-
- org.ldaptive.AbstractConnectionStrategy
-
- All Implemented Interfaces:
java.lang.Iterable<LdapURL>
,ConnectionStrategy
- Direct Known Subclasses:
ActivePassiveConnectionStrategy
,DnsResolverConnectionStrategy
,DnsSrvConnectionStrategy
,RandomConnectionStrategy
,RoundRobinConnectionStrategy
public abstract class AbstractConnectionStrategy extends java.lang.Object implements ConnectionStrategy
Base class for connection strategy implementations.- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractConnectionStrategy.DefaultLdapURLIterator
Default iterator implementation.
-
Field Summary
Fields Modifier and Type Field Description protected LdapURLSet
ldapURLSet
Set of LDAP URLs to attempt connections to.protected org.slf4j.Logger
logger
Logger for this class.
-
Constructor Summary
Constructors Constructor Description AbstractConnectionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
failure(LdapURL url)
Indicates the supplied URL could not be connected to.java.util.function.Predicate<LdapURL>
getActivateCondition()
Returns the condition used to activate connections.java.util.function.Predicate<LdapURL>
getRetryCondition()
Returns the condition used to determine whether to attempt to activate a connection.void
initialize(java.lang.String urls, java.util.function.Predicate<LdapURL> condition)
Prepare this strategy for use.boolean
isInitialized()
Whether this strategy is ready for use.void
populate(java.lang.String urls, LdapURLSet urlSet)
Populates aLdapURLSet
from the URL string provided at configuration time.void
setRetryCondition(java.util.function.Predicate<LdapURL> condition)
Sets the retry condition which determines whether an attempt should be made to activate a URL.void
success(LdapURL url)
Indicates the supplied URL was successfully connected to.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ldaptive.ConnectionStrategy
newInstance
-
-
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
Logger for this class.
-
ldapURLSet
protected LdapURLSet ldapURLSet
Set of LDAP URLs to attempt connections to.
-
-
Method Detail
-
isInitialized
public boolean isInitialized()
Description copied from interface:ConnectionStrategy
Whether this strategy is ready for use.- Specified by:
isInitialized
in interfaceConnectionStrategy
- Returns:
- whether this strategy is ready for use
-
initialize
public void initialize(java.lang.String urls, java.util.function.Predicate<LdapURL> condition)
Description copied from interface:ConnectionStrategy
Prepare this strategy for use.- Specified by:
initialize
in interfaceConnectionStrategy
- Parameters:
urls
- LDAP URLs for this strategycondition
- predicate to determine whether a connection is active
-
populate
public void populate(java.lang.String urls, LdapURLSet urlSet)
Description copied from interface:ConnectionStrategy
Populates aLdapURLSet
from the URL string provided at configuration time.- Specified by:
populate
in interfaceConnectionStrategy
- Parameters:
urls
- Space-delimited string of URLs describing the LDAP hosts to connect to. The URLs in the string are commonlyldap://
orldaps://
URLs that directly describe the hosts to connect to, but may also describe a resource from which to obtain LDAP connection URLs as is the case forDnsSrvConnectionStrategy
that use URLs with the schemedns:
.urlSet
- LDAP URL set to populate.
-
getActivateCondition
public java.util.function.Predicate<LdapURL> getActivateCondition()
Description copied from interface:ConnectionStrategy
Returns the condition used to activate connections.- Specified by:
getActivateCondition
in interfaceConnectionStrategy
- Returns:
- activate condition
-
getRetryCondition
public java.util.function.Predicate<LdapURL> getRetryCondition()
Description copied from interface:ConnectionStrategy
Returns the condition used to determine whether to attempt to activate a connection.- Specified by:
getRetryCondition
in interfaceConnectionStrategy
- Returns:
- retry condition
-
setRetryCondition
public void setRetryCondition(java.util.function.Predicate<LdapURL> condition)
Sets the retry condition which determines whether an attempt should be made to activate a URL.- Parameters:
condition
- that determines whether to test an inactive URL
-
success
public void success(LdapURL url)
Description copied from interface:ConnectionStrategy
Indicates the supplied URL was successfully connected to.- Specified by:
success
in interfaceConnectionStrategy
- Parameters:
url
- which was successfully connected to
-
failure
public void failure(LdapURL url)
Description copied from interface:ConnectionStrategy
Indicates the supplied URL could not be connected to.- Specified by:
failure
in interfaceConnectionStrategy
- Parameters:
url
- which was could not be connected to
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-