diff --git a/spring-ldap/docs/reference/src/contextprocessor.xml b/spring-ldap/docs/reference/src/contextprocessor.xml
index dae84b91..9f8bf51c 100644
--- a/spring-ldap/docs/reference/src/contextprocessor.xml
+++ b/spring-ldap/docs/reference/src/contextprocessor.xml
@@ -86,8 +86,7 @@ public void search(String base, String filter,
public abstract Control createRequestControl();
}
- This is what it can look like when you implement your own request
- control DirContextProcessor:
+ A typical DirContextProcessor will be similar to the following:
@@ -158,7 +157,7 @@ public class MyCoolRequestControl extends AbstractRequestControlDirContextProces
called with a paged results request.
Spring LDAP provides support for paged results by leveraging the
- concept for pre- and postprocessing of an LdapContext that was discussed
+ concept for pre- and postprocessing of an LdapContext that was discussed
in the previous sections. It does so by providing two classes:
PagedResultsRequestControl and
PagedResultsCookie. The
@@ -173,54 +172,29 @@ public class MyCoolRequestControl extends AbstractRequestControlDirContextProces
this cookie between searches, Spring LDAP provides the wrapper class
PagedResultsCookie.
- This is an example of how the paged search results functionality can
+ Below is an example of how the paged search results functionality may
be used:
- Example of an integration test for paged search results
+ Paged results using PagedResultsRequestControl
- public class LdapTemplatePagedSearchITest extends TestCase {
- private LdapTemplate tested;
- ...
- // LDAP contains 5 persons matching the filter. Page size is 3.
- // Expects two batches of 3 and 2 persons respectively.
- public void testPagedResult() {
- SearchControls searchControls = new SearchControls();
- searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- String base = "dc=example,dc=com";
- String filter = "(&(objectclass=person)(cn=Some Person*))";
- PersonAttributesMapper mapper = new PersonAttributesMapper();
- CollectingNameClassPairCallbackHandler handler =
- tested.new AttributesMapperCallbackHandler(mapper);
-
- PagedResultsRequestControl requestControl;
- requestControl = new PagedResultsRequestControl(3);
- tested.search(base, filter, searchControls, handler, requestControl);
- PagedResultsCookie cookie = requestControl.getCookie();
- assertNotNull("Cookie should not be null yet", cookie.getCookie());
- assertEquals(3, callbackHandler.getList().size());
-
- // Prepare for second and last search
- requestControl = new PagedResultsRequestControl(3, cookie);
- tested.search(base, filter, searchControls, handler, requestControl);
- cookie = requestControl.getCookie();
- assertNull("Cookie should be null now", cookie.getCookie());
- assertEquals(5, callbackHandler.getList().size());
- }
+ public PagedResult getAllPersons(PagedResultsCookie cookie) {
+ PagedResultsRequestControl control = new PagedResultsRequestControl(PAGE_SIZE, cookie);
+ SearchControls searchControls = new SearchControls();
+ searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ List persons = ldapTemplate.search("", "objectclass=person", searchControls, control);
+
+ return new PagedResult(persons, control.getCookie());
+ }
-
- Important to note here is that we use the same
- CollectingNameClassPairCallbackHandler for both
- searches. This means that the results are appended to the same list. The
- second batch of two are added to the first three, giving a total of five
- after the second search.
-
- When using the PagedResultsRequestControl it is imperative
- that you keep track of the cookie returned from an operation and supply the same
- instance to subsequent calls. This means that your Dao method will typically need to
- wrap the result list together with the cookie in the value returned to the higher tiers.
-
+ In the first call to this method, null will be supplied as
+ the cookie parameter. On subsequent calls the client will need to supply the cookie from
+ the last search (returned wrapped in the PagedResult) each time the
+ method is called. When the actual cookie is null (i.e.
+ pagedResult.getCookie().getCookie() returns null),
+ the last batch has been returned from the search.
\ No newline at end of file
diff --git a/spring-ldap/docs/reference/src/simple.xml b/spring-ldap/docs/reference/src/simple.xml
index 828de5a0..95056634 100644
--- a/spring-ldap/docs/reference/src/simple.xml
+++ b/spring-ldap/docs/reference/src/simple.xml
@@ -1,7 +1,7 @@
- Spring LDAP Java 5 Support
+ Java 5 Support
SimpleLdapTemplate