Class ConnectionHandler

    • Method Detail

      • getConnectionHandler

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

        public void initializeLocalEntryConnectionMapping​(String connector,
                                                          String connectionName,
                                                          org.apache.synapse.MessageContext messageContext)
        Initialize local entry connection mapping
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        messageContext - Message Context
      • createConnection

        public void createConnection​(String connector,
                                     String connectionName,
                                     ConnectionFactory factory,
                                     Configuration configuration,
                                     org.apache.synapse.MessageContext messageContext)
        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
        messageContext - Message Context
      • createConnection

        public void createConnection​(String connector,
                                     String connectionName,
                                     Connection connection,
                                     org.apache.synapse.MessageContext messageContext)
        Stores a new single connection
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        connection - Connection to be stored
        messageContext - Message Context
      • 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
      • removeLocalEntryConnections

        public void removeLocalEntryConnections​(String localEntryName)
        remove local entry and associate connections from local entry store and connection map
        Parameters:
        localEntryName -
      • 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
      • getStatusOfConnection

        public boolean getStatusOfConnection​(String connector,
                                             String connectionName)
        Retrieves whether the connection pool or not
        Parameters:
        connector - Name of the connector
        connectionName - Name of the connection
        Returns:
        the connection pool status