Class LdapAnonConnFactory

  • All Implemented Interfaces:
    com.netscape.certsrv.ldap.ILdapConnFactory

    public class LdapAnonConnFactory
    extends java.lang.Object
    implements com.netscape.certsrv.ldap.ILdapConnFactory
    Factory for getting LDAP Connections to a LDAP server each connection is a seperate thread that can be bound to a different authentication dn and password.
    • Constructor Summary

      Constructors 
      Constructor Description
      LdapAnonConnFactory​(java.lang.String id)
      Constructor for initializing from the config store.
      LdapAnonConnFactory​(java.lang.String id, boolean defErrorIfDown)  
      LdapAnonConnFactory​(java.lang.String id, int minConns, int maxConns, int maxResults, LdapConnInfo connInfo)
      Constructor for LdapAnonConnFactory
      LdapAnonConnFactory​(java.lang.String id, int minConns, int maxConns, LdapConnInfo connInfo)
      Constructor for LdapAnonConnFactory
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void finalize()  
      int freeConn()
      Returns the number of free connections available from this pool.
      netscape.ldap.LDAPConnection getConn()
      Gets connection from this factory.
      netscape.ldap.LDAPConnection getConn​(boolean waitForConn)
      Returns a LDAP connection - a clone of the master connection.
      LdapConnInfo getConnInfo()
      returns connection info.
      protected void init()
      initialize routine from parameters.
      void init​(PKISocketConfig config)  
      void init​(PKISocketConfig config, LDAPConfig dbConfig)  
      protected void makeMinimum​(boolean errorIfDown)
      make the mininum configured connections
      int maxConn()
      Returns the maximum number of connections available from this pool.
      void reset()
      resets this factory - if no connections outstanding, disconnections all connections and resets everything to 0 as if no connections were ever made.
      void returnConn​(netscape.ldap.LDAPConnection conn)
      Returns a connection to the factory for recycling.
      int totalConn()
      Returns the number of total connections available from this pool.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
      • id

        protected java.lang.String id
      • mMinConns

        protected int mMinConns
      • mMaxConns

        protected int mMaxConns
      • mMaxResults

        protected int mMaxResults
      • PROP_ERROR_IF_DOWN

        public static final java.lang.String PROP_ERROR_IF_DOWN
        See Also:
        Constant Field Values
    • Constructor Detail

      • LdapAnonConnFactory

        public LdapAnonConnFactory​(java.lang.String id)
        Constructor for initializing from the config store. must be followed by init(IConfigStore)
      • LdapAnonConnFactory

        public LdapAnonConnFactory​(java.lang.String id,
                                   boolean defErrorIfDown)
      • LdapAnonConnFactory

        public LdapAnonConnFactory​(java.lang.String id,
                                   int minConns,
                                   int maxConns,
                                   LdapConnInfo connInfo)
                            throws com.netscape.certsrv.ldap.ELdapException
        Constructor for LdapAnonConnFactory
        Parameters:
        minConns - minimum number of connections to have available
        maxConns - max number of connections to have available. This is the maximum number of clones of this connection one wants to allow.
        serverInfo - server connection info - host, port, etc.
        Throws:
        com.netscape.certsrv.ldap.ELdapException
      • LdapAnonConnFactory

        public LdapAnonConnFactory​(java.lang.String id,
                                   int minConns,
                                   int maxConns,
                                   int maxResults,
                                   LdapConnInfo connInfo)
                            throws com.netscape.certsrv.ldap.ELdapException
        Constructor for LdapAnonConnFactory
        Parameters:
        minConns - minimum number of connections to have available
        maxConns - max number of connections to have available. This is the maximum number of clones of this connection one wants to allow.
        maxResults - max number of results to return per query
        serverInfo - server connection info - host, port, etc.
        Throws:
        com.netscape.certsrv.ldap.ELdapException
    • Method Detail

      • totalConn

        public int totalConn()
        Description copied from interface: com.netscape.certsrv.ldap.ILdapConnFactory
        Returns the number of total connections available from this pool. Includes sum of free and in use connections.
        Specified by:
        totalConn in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Returns:
        Integer number of total connections.
      • freeConn

        public int freeConn()
        Description copied from interface: com.netscape.certsrv.ldap.ILdapConnFactory
        Returns the number of free connections available from this pool.
        Specified by:
        freeConn in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Returns:
        Integer number of free connections.
      • maxConn

        public int maxConn()
        Description copied from interface: com.netscape.certsrv.ldap.ILdapConnFactory
        Returns the maximum number of connections available from this pool.
        Specified by:
        maxConn in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Returns:
        Integer maximum number of connections.
      • init

        public void init​(PKISocketConfig config)
                  throws com.netscape.certsrv.ldap.ELdapException
        Throws:
        com.netscape.certsrv.ldap.ELdapException
      • init

        protected void init()
                     throws com.netscape.certsrv.ldap.ELdapException
        initialize routine from parameters.
        Throws:
        com.netscape.certsrv.ldap.ELdapException
      • makeMinimum

        protected void makeMinimum​(boolean errorIfDown)
                            throws com.netscape.certsrv.ldap.ELdapException
        make the mininum configured connections
        Throws:
        com.netscape.certsrv.ldap.ELdapException
      • getConn

        public netscape.ldap.LDAPConnection getConn()
                                             throws com.netscape.certsrv.ldap.ELdapException
        Gets connection from this factory. All connections gotten from this factory must be returned. If not the max number of connections may be reached prematurely. The best thing to put returnConn in a finally clause so it always gets called. For example,
         LDAPConnection c = null;
         try {
             c = factory.getConn();
             myclass.do_something_with_c(c);
         } catch (ELdapException e) {
             handle_error_here();
         } finally {
             factory.returnConn(c);
         }
         
        Specified by:
        getConn in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Returns:
        Ldap connection object. connection is not available
        Throws:
        com.netscape.certsrv.ldap.ELdapException - if any error occurs, such as a
      • getConn

        public netscape.ldap.LDAPConnection getConn​(boolean waitForConn)
                                             throws com.netscape.certsrv.ldap.ELdapException
        Returns a LDAP connection - a clone of the master connection. All connections should be returned to the factory using returnConn() to recycle connection objects. If not returned the limited max number is affected but if that number is large not much harm is done. Returns null if maximum number of connections reached.

        The best thing to put returnConn in a finally clause so it always gets called. For example,

         LDAPConnection c = null;
         try {
             c = factory.getConn();
             myclass.do_something_with_c(c);
         } catch (ELdapException e) {
             handle_error_here();
         } finally {
             factory.returnConn(c);
         }
         
        Throws:
        com.netscape.certsrv.ldap.ELdapException
      • returnConn

        public void returnConn​(netscape.ldap.LDAPConnection conn)
        Returns a connection to the factory for recycling. All connections gotten from this factory must be returned. If not the max number of connections may be reached prematurely.

        The best thing to put returnConn in a finally clause so it always gets called. For example,

         LDAPConnection c = null;
         try {
             c = factory.getConn();
             myclass.do_something_with_c(c);
         } catch (ELdapException e) {
             handle_error_here();
         } finally {
             factory.returnConn(c);
         }
         
        Specified by:
        returnConn in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Parameters:
        conn - Ldap connection object to be returned to the free list of the pool.
      • finalize

        protected void finalize()
                         throws java.lang.Exception
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Exception
      • getConnInfo

        public LdapConnInfo getConnInfo()
        returns connection info.
      • reset

        public void reset()
                   throws com.netscape.certsrv.ldap.ELdapException
        resets this factory - if no connections outstanding, disconnections all connections and resets everything to 0 as if no connections were ever made. intended to be called just before shutdown or exit to disconnection & cleanup connections.
        Specified by:
        reset in interface com.netscape.certsrv.ldap.ILdapConnFactory
        Throws:
        com.netscape.certsrv.ldap.ELdapException