Package org.springframework.ldap.control
Class PagedResultsDirContextProcessor
- java.lang.Object
-
- org.springframework.ldap.control.AbstractRequestControlDirContextProcessor
-
- org.springframework.ldap.control.AbstractFallbackRequestAndResponseControlDirContextProcessor
-
- org.springframework.ldap.control.PagedResultsDirContextProcessor
-
- All Implemented Interfaces:
DirContextProcessor
public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndResponseControlDirContextProcessor
DirContextProcessor implementation for managing the paged results control. Note that due to the internal workings ofLdapTemplate
, the target connection is closed after each LDAP call. The PagedResults control require the same connection be used for each call, which means we need to make sure the target connection is never actually closed. There's basically two ways of making this happen: use theSingleContextSource
implementation or make sure all calls happen within a single LDAP transaction (usingContextSourceTransactionManager
).
-
-
Field Summary
-
Fields inherited from class org.springframework.ldap.control.AbstractFallbackRequestAndResponseControlDirContextProcessor
critical, defaultRequestControl, defaultResponseControl, fallbackRequestControl, fallbackResponseControl, requestControlClass, responseControlClass
-
Fields inherited from class org.springframework.ldap.control.AbstractRequestControlDirContextProcessor
log
-
-
Constructor Summary
Constructors Constructor Description PagedResultsDirContextProcessor(int pageSize)
Constructs a new instance.PagedResultsDirContextProcessor(int pageSize, PagedResultsCookie cookie)
Constructs a new instance with the supplied page size and cookie.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.naming.ldap.Control
createRequestControl()
Create an instance of the appropriate RequestControl.PagedResultsCookie
getCookie()
Get the cookie.int
getPageSize()
Get the page size.int
getResultSize()
Get the total estimated number of entries that matches the issued search.protected void
handleResponse(java.lang.Object control)
boolean
hasMore()
Check whether there are more results to retrieved.-
Methods inherited from class org.springframework.ldap.control.AbstractFallbackRequestAndResponseControlDirContextProcessor
createRequestControl, invokeMethod, loadControlClasses, postProcess, setCritical, setRequestControlClass, setResponseControlClass
-
Methods inherited from class org.springframework.ldap.control.AbstractRequestControlDirContextProcessor
isReplaceSameControlEnabled, preProcess, setReplaceSameControlEnabled
-
-
-
-
Constructor Detail
-
PagedResultsDirContextProcessor
public PagedResultsDirContextProcessor(int pageSize)
Constructs a new instance. This constructor should be used when performing the first paged search operation, when no other results have been retrieved.- Parameters:
pageSize
- the page size.
-
PagedResultsDirContextProcessor
public PagedResultsDirContextProcessor(int pageSize, PagedResultsCookie cookie)
Constructs a new instance with the supplied page size and cookie. The cookie must be the exact same instance as received from a previous paged results search, ornull
if it is the first in an operation sequence.- Parameters:
pageSize
- the page size.cookie
- the cookie, as received from a previous search.
-
-
Method Detail
-
getCookie
public PagedResultsCookie getCookie()
Get the cookie.
-
getPageSize
public int getPageSize()
Get the page size.- Returns:
- the page size.
-
getResultSize
public int getResultSize()
Get the total estimated number of entries that matches the issued search. Note that this value is optional for the LDAP server to return, so it does not always contain any valid data.- Returns:
- the estimated result size, if returned from the server.
-
createRequestControl
public javax.naming.ldap.Control createRequestControl()
Description copied from class:AbstractRequestControlDirContextProcessor
Create an instance of the appropriate RequestControl.- Specified by:
createRequestControl
in classAbstractRequestControlDirContextProcessor
- Returns:
- the new instance.
-
hasMore
public boolean hasMore()
Check whether there are more results to retrieved. When there are no more results to retrieve, this is indicated by anull
cookie being returned from the server. When this happen, the internal status will set to false.- Returns:
true
if there are more results to retrieve,false
otherwise.- Since:
- 2.0
-
handleResponse
protected void handleResponse(java.lang.Object control)
- Specified by:
handleResponse
in classAbstractFallbackRequestAndResponseControlDirContextProcessor
-
-