Package org.ldaptive

Class SingleConnectionFactory

    • Field Detail

      • initialized

        private boolean initialized
        Whether initialize() has been successfully invoked.
      • failFastInitialize

        private boolean failFastInitialize
        Whether initialize() should throw if the connection cannot be opened.
      • nonBlockingInitialize

        private boolean nonBlockingInitialize
        Whether initialize() should occur on a separate thread.
      • factoryExecutor

        private ExecutorService factoryExecutor
        Executor for scheduling factory tasks.
    • Constructor Detail

      • SingleConnectionFactory

        public SingleConnectionFactory()
        Default constructor.
      • SingleConnectionFactory

        public SingleConnectionFactory​(Transport t)
        Creates a new single connection factory.
        Parameters:
        t - transport
      • SingleConnectionFactory

        public SingleConnectionFactory​(String ldapUrl)
        Creates a new single connection factory.
        Parameters:
        ldapUrl - to connect to
      • SingleConnectionFactory

        public SingleConnectionFactory​(String ldapUrl,
                                       Transport t)
        Creates a new single connection factory.
        Parameters:
        ldapUrl - to connect to
        t - transport
      • SingleConnectionFactory

        public SingleConnectionFactory​(ConnectionConfig cc)
        Creates a new single connection factory.
        Parameters:
        cc - connection configuration
      • SingleConnectionFactory

        public SingleConnectionFactory​(ConnectionConfig cc,
                                       Transport t)
        Creates a new single connection factory.
        Parameters:
        cc - connection configuration
        t - transport
    • Method Detail

      • getFailFastInitialize

        public boolean getFailFastInitialize()
        Returns whether initialize() should throw if the connection cannot be opened.
        Returns:
        whether initialize() should throw
      • setFailFastInitialize

        public void setFailFastInitialize​(boolean b)
        Sets whether initialize() should throw if the connection cannot be opened.
        Parameters:
        b - whether initialize() should throw
      • getNonBlockingInitialize

        public boolean getNonBlockingInitialize()
        Returns whether initialize() should execute on a separate thread.
        Returns:
        whether initialize() should block
      • setNonBlockingInitialize

        public void setNonBlockingInitialize​(boolean b)
        Sets whether initialize() should execute on a separate thread.
        Parameters:
        b - whether initialize() should block
      • getOnOpen

        public Predicate<Connection> getOnOpen()
        Returns the function to run when the connection is opened.
        Returns:
        on open function
      • setOnOpen

        public void setOnOpen​(Predicate<Connection> function)
        Sets the function to run when the connection is opened.
        Parameters:
        function - to run on connection open
      • getOnClose

        public Predicate<Connection> getOnClose()
        Returns the function to run when the connection is closed.
        Returns:
        on close function
      • setOnClose

        public void setOnClose​(Predicate<Connection> function)
        Sets the function to run when the connection is closed.
        Parameters:
        function - to run on connection close
      • getValidator

        public ConnectionValidator getValidator()
        Returns the connection validator for this factory.
        Returns:
        connection validator
      • setValidator

        public void setValidator​(ConnectionValidator cv)
        Sets the connection validator for this factory.
        Parameters:
        cv - connection validator
      • isInitialized

        public boolean isInitialized()
        Returns whether this factory has been initialized.
        Returns:
        whether this factory has been initialized
      • initialize

        public void initialize()
                        throws LdapException
        Prepares this factory for use.
        Throws:
        LdapException - if the connection cannot be opened
      • initializeConnectionProxy

        private void initializeConnectionProxy()
                                        throws LdapException
        Opens the connection and creates the connection proxy. Invokes onOpen and will tear down the connection if that function returns false.
        Throws:
        LdapException - if connection open fails
      • destroyConnectionProxy

        private void destroyConnectionProxy()
        Closes the connection and sets the proxy to null. Invokes onClose prior to closing the connection.