org.springframework.ldap.control

## Class AbstractRequestControlDirContextProcessor

- java.lang.Object
- - org.springframework.ldap.control.AbstractRequestControlDirContextProcessor

- All Implemented Interfaces:
    DirContextProcessor
  Direct Known Subclasses:
    AbstractFallbackRequestAndResponseControlDirContextProcessor, PagedResultsRequestControl

      public abstract class AbstractRequestControlDirContextProcessor
      extends Object
      implements DirContextProcessor

  Abstract superclass with responsibility to apply a single RequestControl on an LdapContext, preserving any existing controls. Subclasses should implement `DirContextProcessor.postProcess(DirContext)` and template method `createRequestControl()`.
  Author:
    Mattias Hellborg Arthursson, Ulrik Sandberg

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.slf4j.Logger` | `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractRequestControlDirContextProcessor()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract Control` | `createRequestControl()` Create an instance of the appropriate RequestControl.
    `boolean` | `isReplaceSameControlEnabled()` If there already exists a request control of the same class as the one created by `createRequestControl()` in the context, the new control can either replace the existing one (default behavior) or be added.
    `void` | `preProcess(DirContext ctx)` Get the existing RequestControls from the LdapContext, call `createRequestControl()` to get a new instance, build a new array of Controls and set it on the LdapContext.
    `void` | `setReplaceSameControlEnabled(boolean replaceSameControlEnabled)` If there already exists a request control of the same class as the one created by `createRequestControl()` in the context, the new control can either replace the existing one (default behavior) or be added.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.ldap.core.DirContextProcessor

      `postProcess`

- - ### Field Detail

    - #### log

          protected org.slf4j.Logger log

  - ### Constructor Detail

    - #### AbstractRequestControlDirContextProcessor

          public AbstractRequestControlDirContextProcessor()

  - ### Method Detail

    - #### isReplaceSameControlEnabled

          public boolean isReplaceSameControlEnabled()

      If there already exists a request control of the same class as the one created by `createRequestControl()` in the context, the new control can either replace the existing one (default behavior) or be added.
      Returns:
        true if an already existing control will be replaced

    - #### setReplaceSameControlEnabled

          public void setReplaceSameControlEnabled(boolean replaceSameControlEnabled)

      If there already exists a request control of the same class as the one created by `createRequestControl()` in the context, the new control can either replace the existing one (default behavior) or be added.
      Parameters:
        `replaceSameControlEnabled` - `true` if an already existing control should be replaced

    - #### preProcess

          public void preProcess(DirContext ctx)
                          throws NamingException

      Get the existing RequestControls from the LdapContext, call `createRequestControl()` to get a new instance, build a new array of Controls and set it on the LdapContext.

      The `Control` feature is specific for LDAP v3 and thus applies only to `LdapContext`. However, the generic DirContextProcessor mechanism used for calling `preProcess` and `postProcess` uses DirContext, since it also works for LDAP v2. This is the reason that DirContext has to be cast to a LdapContext.

      Specified by:
        `preProcess` in interface `DirContextProcessor`
      Parameters:
        `ctx` - an LdapContext instance.
      Throws:
        `NamingException`
        `IllegalArgumentException` - if the supplied DirContext is not an LdapContext.

    - #### createRequestControl

          public abstract Control createRequestControl()

      Create an instance of the appropriate RequestControl.
      Returns:
        the new instance.