Package org.springframework.ldap.control
Class ControlExchangeDirContextProcessor<S extends Control,T extends Control>
java.lang.Object
org.springframework.ldap.control.ControlExchangeDirContextProcessor<S,T>
- All Implemented Interfaces:
DirContextProcessor
- Direct Known Subclasses:
PagedResultsControlExchangeDirContextProcessor
public class ControlExchangeDirContextProcessor<S extends Control,T extends Control>
extends Object
implements DirContextProcessor
A generic
DirContextProcessor implementation for managing LDAP request and
response controls through a ControlExchange.
This processor handles the lifecycle of LDAP controls by:
- Adding the request control from the exchange to the
LdapContextbefore operations - Extracting matching response controls after operations
- Updating the exchange with the response control for subsequent operations
For stateful controls that require maintaining connection state across multiple
operations (such as paged results or server-side sorting), the same LDAP connection
must be reused. Spring LDAP's
SingleContextSource and
TransactionAwareContextSourceProxy
provide this capability when wired into
LdapTemplate and
LdapClient instances.
-
Constructor Summary
ConstructorsConstructorDescriptionControlExchangeDirContextProcessor(ControlExchange<S, T> exchange) Construct thisDirContextProcessor, providing theControlExchangeto use -
Method Summary
Modifier and TypeMethodDescriptionReturns the current control exchange containing the request and response controls.voidpostProcess(DirContext ctx) Extracts the response control matching the request control's ID from theLdapContextand updates the exchange.voidpreProcess(DirContext ctx) Adds the request control from the exchange to theLdapContext, replacing any existing control with the same ID.
-
Constructor Details
-
ControlExchangeDirContextProcessor
Construct thisDirContextProcessor, providing theControlExchangeto use- Parameters:
exchange- theControlExchangeto use for managing request and response controls
-
-
Method Details
-
preProcess
Adds the request control from the exchange to theLdapContext, replacing any existing control with the same ID.- Specified by:
preProcessin interfaceDirContextProcessor- Parameters:
ctx- theDirContextto pre-process; must be an instance ofLdapContext- Throws:
NamingException- if an error occurs while processingIllegalArgumentException- ifctxis not anLdapContext
-
postProcess
Extracts the response control matching the request control's ID from theLdapContextand updates the exchange.- Specified by:
postProcessin interfaceDirContextProcessor- Parameters:
ctx- theDirContextto post-process; must be an instance ofLdapContext- Throws:
NamingException- if an error occurs while processingIllegalArgumentException- ifctxis not anLdapContext
-
getExchange
Returns the current control exchange containing the request and response controls.The exchange is updated after each
postProcess(DirContext)call when a matching response control is found.- Returns:
- the current
ControlExchange
-