Table of Contents
In some situations, one would like to perform operations on the
DirContext
before and after the search operation. The
interface that is used for this is called
DirContextProcessor
:
public interface DirContextProcessor { public void preProcess(DirContext ctx) throws NamingException; public void postProcess(DirContext ctx) throws NamingException; }
The LdapTemplate
class has a search method that
takes a DirContextProcessor
:
public void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor) throws DataAccessException;
Before the search operation, the preProcess
method is called on the given DirContextProcessor
instance. After the search has been executed and the resulting
NamingEnumeration
has been processed, the
postProcess
method is called. This enables a user to
perform operations on the DirContext
to be used in the
search, and to check the DirContext
when the search has
been performed. This can be very useful for example when handling request
and response controls.
There are also a few convenience methods for those that don't need a
custom SearchExecutor
:
public void search(Name base, String filter, SearchControls controls, NameClassPairCallbackHandler handler, DirContextProcessor processor) public void search(String base, String filter, SearchControls controls, NameClassPairCallbackHandler handler, DirContextProcessor processor) public void search(Name base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) public void search(String base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) public void search(Name base, String filter, SearchControls controls, ContextMapper mapper, DirContextProcessor processor) public void search(String base, String filter, SearchControls controls, ContextMapper mapper, DirContextProcessor processor)