Skip navigation links

Class PooledLDAPConnectionFactory

    • Constructor Detail

      • PooledLDAPConnectionFactory

        public PooledLDAPConnectionFactory()
    • Method Detail

      • makeObject

        public Object makeObject()
                          throws com.novell.ldap.LDAPException
        Constructs a new PooledLDAPConnection object, including: passing it the connection manager so it can return itself to the pool if it falls out of scope, setting a default set of constraints, connecting to the server, initiating TLS if needed. Lastly it optionally binds as the "auto-bind user" and clears the bindAttempted flag so we will know if a user of the connection attempts to rebind it.
        Specified by:
        makeObject in interface org.apache.commons.pool.PoolableObjectFactory
      • activateObject

        public void activateObject(Object obj)
                            throws com.novell.ldap.LDAPException
        Activates a PooledLDAPConnection as it is being loaned out from the pool, including: ensuring the default constraints are set and setting the active flag so that it can return itself to the pool if it falls out of scope.
        Specified by:
        activateObject in interface org.apache.commons.pool.PoolableObjectFactory
      • passivateObject

        public void passivateObject(Object obj)
                             throws com.novell.ldap.LDAPException
        Passivates a PooledLDAPConnection as it is being returned to the pool, including: clearing the active flag so that it won't attempt to return itself to the pool.
        Specified by:
        passivateObject in interface org.apache.commons.pool.PoolableObjectFactory
      • validateObject

        public boolean validateObject(Object obj)
        Validates a PooledLDAPConnection by checking if the connection is alive and ensuring it is properly bound as the autoBind user. If a borrower attempted to rebind the connection, then the bindAttempted flag will be true -- in that case rebind it as the autoBind user and clear the bindAttempted flag.
        Specified by:
        validateObject in interface org.apache.commons.pool.PoolableObjectFactory
      • destroyObject

        public void destroyObject(Object obj)
                           throws Exception
        Cleans up a PooledLDAPConnection that is about to be destroyed by invoking LDAPConnection.disconnect(). To ensure that the object is not inadvertently returned to the pool again by a finalize() call, the connection's active flag is lowered prior to the disconnect() call. Does nothing but log a pair of debug messages if the received object is not a PooledLDAPConnection.
        Specified by:
        destroyObject in interface org.apache.commons.pool.PoolableObjectFactory
      • getConnectionManager

        public LdapConnectionManager getConnectionManager()
        Gives the LdapConnectionMananger that the Factory is using to configure its PooledLDAPConnections.
      • setConnectionManager

        public void setConnectionManager(LdapConnectionManager connectionManager)
        Sets the LdapConnectionManager that the Factory will use to configure and manage its PooledLDAPConnections. This includes gathering all the connection information (host, port, user, passord), setting the SocketFactory, determining if we are using TLS, and creating the default constraints.
        connectionManager - the LdapConnectionManager to use
      • setConnectionLivenessValidator

        public void setConnectionLivenessValidator(LdapConnectionLivenessValidator livenessValidator)
        Assign a strategy for verifying LDAPConnection liveness. Defaults to an instance of NativeLdapConnectionLivenessValidator.
        livenessValidator - an object implementing a liveness validation strategy. Pass null to force default behavior.
      • getConnectionLivenessValidator

        public LdapConnectionLivenessValidator getConnectionLivenessValidator()
        Access the strategy for verifying LDAPConnection liveness. Will not return null.
        the current connection liveness validator.
      • getHost

        protected String getHost()
        Get the host to connect to. Attempt to resolve all addresses for a hostname when round robin DNS is used. We do this resolution low down in the stack as we don't want the results cached at all. Unless configured otherwise the JVM will cache DNS lookups. Even if this is just for 30 seconds (default in 1.6/1.7) it means when the pool is getting prebuilt at startup the connections will all point to the same server.
        A hostname or a space separated string of IP addresses to connect to.

Copyright © 2003–2019 The Sakai Foundation. All rights reserved.