Interface DirContextFactory
-
- All Known Implementing Classes:
SimpleDirContextFactoryBuilder.SimpleDirContextFactory
public interface DirContextFactoryFactory 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 classDirContextFactory.ReferralModeThe referral mode.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voiddiscardContext(DirContext context)Pass back aDirContextto this factory to be discarded.DirContextobtainDirContext(CallbackHandler handler, DirContextFactory.ReferralMode mode)Obtain aDirContextbased on the credentials extracted from the givenCallbackHandler.DirContextobtainDirContext(DirContextFactory.ReferralMode mode)Obtain aDirContextfor the configured referral mode.voidreturnContext(DirContext context)Return theDirContextonce it is no longer required.
-
-
-
Method Detail
-
obtainDirContext
DirContext obtainDirContext(DirContextFactory.ReferralMode mode) throws NamingException
Obtain aDirContextfor the configured referral mode.- Parameters:
mode- the referral mode for if a referral is encountered querying LDAP; the passed in referral mode can benullin which case the default ofIGNOREwill be assumed- Returns:
- a ready to use
DirContextfor searching and attribute retrieval - Throws:
NamingException
-
obtainDirContext
DirContext obtainDirContext(CallbackHandler handler, DirContextFactory.ReferralMode mode) throws NamingException
Obtain aDirContextbased 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 benullin which case the default ofIGNOREwill be assumed- Returns:
- a ready to use
DirContextfor searching and attribute retrieval - Throws:
NamingException
-
returnContext
void returnContext(DirContext context)
Return theDirContextonce it is no longer required. The returned DirContext is not necessarily anInitialDirContextand as a result we can not assume it is closeable. Should only be called if a context was successfully obtained.- Parameters:
context- theDirContextto return
-
discardContext
default void discardContext(DirContext context)
Pass back aDirContextto 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- theDirContextto discard.
-
-