Class ConnectionHandler
- java.lang.Object
-
- org.wso2.carbon.connector.core.connection.ConnectionHandler
-
public class ConnectionHandler extends Object
Handles the connections
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkIfConnectionExists(String connector, String connectionName)
Check if a connection exists for the connector by the same connection namevoid
createConnection(String connector, String connectionName, Connection connection)
Stores a new single connectionvoid
createConnection(String connector, String connectionName, ConnectionFactory factory, Configuration configuration)
Creates a new connection pool and stores the connectionConnection
getConnection(String connector, String connectionName)
Retrieve connection by connector name and connection namestatic ConnectionHandler
getConnectionHandler()
Gets the Connection Handler instanceboolean
getStatusOfConnection(String connector, String connectionName)
Retrieves whether the connection pool or notvoid
returnConnection(String connector, String connectionName, Connection connection)
Return borrowed connectionvoid
shutdownConnections()
Shutdown all the connection pools and unregister from the handler.void
shutdownConnections(String connector)
Shutdown connection pools for a specified connector and unregister from the handler.
-
-
-
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 connectorconnectionName
- Name of the connectionfactory
- Connection Factory that defines how to create connectionsconfiguration
- 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 connectorconnectionName
- Name of the connectionconnection
- 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 connectorconnectionName
- 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 connectorconnectionName
- Name of the connectionconnection
- 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 connectorconnectionName
- Name of the connection- Returns:
- true if a connection exists, false otherwise
-
-