Directory Client API
  1. Directory Client API
  2. DIRAPI-168

Create an LdapConnectionFactory that is not pooled to create LdapConnection objects for an LdapConnectionConfig

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-M20
    • Fix Version/s: 1.0.0-M23
    • Labels:
      None

      Description

      If using the ldap server for authentication, you do not want a pooled connection because you will be doing a bind operation. However, the ldap connection you want will be otherwise configured the same as your pool of connections. It makes sense to have a factory that can create unbound connections.

      Taking this one step further, the poolable connection factory could use such a connection factory so that the implementation exists in only one place.

      I will attach code that implements this.

      1. DefaultLdapConnectionFactory.java
        2 kB
        lucas theisen
      2. LdapConnectionFactory.java
        2 kB
        lucas theisen
      3. LdapConnections.java
        1 kB
        lucas theisen
      4. PoolableLdapConnectionFactoryWrapper.java
        2 kB
        lucas theisen

        Activity

        Hide
        lucas theisen added a comment -

        If you are willing to merge this in, I can modify anything you find missing.

        Show
        lucas theisen added a comment - If you are willing to merge this in, I can modify anything you find missing.
        Hide
        lucas theisen added a comment -

        Updated DefaultLdapConnectionFactory to use the LdapNetworkConnection constructor that takes an LdapConnectionConfig

        Show
        lucas theisen added a comment - Updated DefaultLdapConnectionFactory to use the LdapNetworkConnection constructor that takes an LdapConnectionConfig
        Hide
        lucas theisen added a comment -

        No need to throw LdapException when calling newLdapConnection (that just calls LdapConnectionFactory.newUnboundLdapConnection)

        Show
        lucas theisen added a comment - No need to throw LdapException when calling newLdapConnection (that just calls LdapConnectionFactory.newUnboundLdapConnection)
        Hide
        Emmanuel Lecharny added a comment -

        There is such a pool of bound connection in a weird place : LdapApiIntegrationUtils.getPooledAdminConnection()

        We should move this method into some more convenient place.

        Show
        Emmanuel Lecharny added a comment - There is such a pool of bound connection in a weird place : LdapApiIntegrationUtils.getPooledAdminConnection() We should move this method into some more convenient place.
        Hide
        lucas theisen added a comment -

        New interface and class were added for connection factory, pooled connection factory was modified in a backwards compatible way to use connection factory instead of config, and connection pool was modified to add a method for getting an unbound connection. The only functional change to previous code was in the implementation of the pooled connection factory in which I modified the passivate (called when a connection is returned) to ensure that it gets re-initialized (in case the borrower bound the connection to a different account, changed the timeout, or the binary attribute detector was changed).

        Show
        lucas theisen added a comment - New interface and class were added for connection factory, pooled connection factory was modified in a backwards compatible way to use connection factory instead of config, and connection pool was modified to add a method for getting an unbound connection. The only functional change to previous code was in the implementation of the pooled connection factory in which I modified the passivate (called when a connection is returned) to ensure that it gets re-initialized (in case the borrower bound the connection to a different account, changed the timeout, or the binary attribute detector was changed).
        Hide
        Emmanuel Lecharny added a comment -

        Thanks for the committed code, Lucs.

        However, could you add the mandatory AL 2.0 header at the top of the
        file, and a header before the created classes, containing a short
        explaination and an @Autor tag ( * @author <a
        href="mailto:dev@directory.apache.org">Apache Directory Project</a>
        )

        Many thanks !

        Show
        Emmanuel Lecharny added a comment - Thanks for the committed code, Lucs. However, could you add the mandatory AL 2.0 header at the top of the file, and a header before the created classes, containing a short explaination and an @Autor tag ( * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> ) Many thanks !
        Hide
        lucas theisen added a comment -

        Whoops, my bad. Fixed in revision 1590323.

        Show
        lucas theisen added a comment - Whoops, my bad. Fixed in revision 1590323.

          People

          • Assignee:
            Unassigned
            Reporter:
            lucas theisen
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development