Interface DirContextFactory
-
- All Known Implementing Classes:
SimpleDirContextFactoryBuilder.SimpleDirContextFactory
public interface DirContextFactory
Factory for obtaining connected DirContext instances. By using a factory for the contexts different strategies can be substituted in a managed environment.- Author:
- Darran Lofthouse
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DirContextFactory.ReferralMode
The referral mode.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
discardContext(DirContext context)
Pass back aDirContext
to this factory to be discarded.DirContext
obtainDirContext(CallbackHandler handler, DirContextFactory.ReferralMode mode)
Obtain aDirContext
based on the credentials extracted from the givenCallbackHandler
.DirContext
obtainDirContext(DirContextFactory.ReferralMode mode)
Obtain aDirContext
for the configured referral mode.void
returnContext(DirContext context)
Return theDirContext
once it is no longer required.
-
-
-
Method Detail
-
obtainDirContext
DirContext obtainDirContext(DirContextFactory.ReferralMode mode) throws NamingException
Obtain aDirContext
for the configured referral mode.- Parameters:
mode
- the referral mode for if a referral is encountered querying LDAP; the passed in referral mode can benull
in which case the default ofIGNORE
will be assumed- Returns:
- a ready to use
DirContext
for searching and attribute retrieval - Throws:
NamingException
-
obtainDirContext
DirContext obtainDirContext(CallbackHandler handler, DirContextFactory.ReferralMode mode) throws NamingException
Obtain aDirContext
based on the credentials extracted from the givenCallbackHandler
.- Parameters:
handler
- the callback handler used to extract credentials in order to obtain a connected DirContext instance.mode
- the referral mode for if a referral is encountered querying LDAP; the passed in referral mode can benull
in which case the default ofIGNORE
will be assumed- Returns:
- a ready to use
DirContext
for searching and attribute retrieval - Throws:
NamingException
-
returnContext
void returnContext(DirContext context)
Return theDirContext
once it is no longer required. The returned DirContext is not necessarily anInitialDirContext
and as a result we can not assume it is closeable. Should only be called if a context was successfully obtained.- Parameters:
context
- theDirContext
to return
-
discardContext
default void discardContext(DirContext context)
Pass back aDirContext
to this factory to be discarded. The context may be passed back either because it is detected as being invalid or possibly because it has been created to act as a specific account and so should not be pooled. Although the context is being discarded this method allows the factory to perform any additional clean up required around this context.- Parameters:
context
- theDirContext
to discard.
-
-