Interface DirContextFactory
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 ClassesModifier and TypeInterfaceDescriptionstatic enumThe referral mode. -
Method Summary
Modifier and TypeMethodDescriptiondefault voiddiscardContext(DirContext context) Pass back aDirContextto this factory to be discarded.obtainDirContext(CallbackHandler handler, DirContextFactory.ReferralMode mode) Obtain aDirContextbased on the credentials extracted from the givenCallbackHandler.Obtain aDirContextfor the configured referral mode.voidreturnContext(DirContext context) Return theDirContextonce it is no longer required.
-
Method Details
-
obtainDirContext
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
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
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.
-