Class ConnectionHandler


  • public class ConnectionHandler
    extends Object
    Handles the connections
    • Method Detail

      • getConnectionHandler

        public static ConnectionHandler getConnectionHandler()
        Gets the Connection Handler instance
        Returns:
        ConnectionHandler instance
      • createConnection

        public void createConnection​(String connector,
                                     String connectionName,
                                     ConnectionFactory factory,
                                     Configuration configuration)
        Creates a new connection pool and stores the connection
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        factory - Connection Factory that defines how to create connections
        configuration - Configurations for the connection pool
      • createConnection

        public void createConnection​(String connector,
                                     String connectionName,
                                     Connection connection)
        Stores a new single connection
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        connection - Connection to be stored
      • getConnection

        public Connection getConnection​(String connector,
                                        String connectionName)
                                 throws ConnectException
        Retrieve connection by connector name and connection name
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        Returns:
        the connection
        Throws:
        ConnectException - if failed to get connection
      • returnConnection

        public void returnConnection​(String connector,
                                     String connectionName,
                                     Connection connection)
        Return borrowed connection
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        connection - Connection to be returned to the pool
      • shutdownConnections

        public void shutdownConnections()
        Shutdown all the connection pools and unregister from the handler.
      • shutdownConnections

        public void shutdownConnections​(String connector)
        Shutdown connection pools for a specified connector and unregister from the handler.
        Parameters:
        connector - Name of the connector
      • checkIfConnectionExists

        public boolean checkIfConnectionExists​(String connector,
                                               String connectionName)
        Check if a connection exists for the connector by the same connection name
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        Returns:
        true if a connection exists, false otherwise