public class ConnectionHandler extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
checkIfConnectionExists(String connector,
String connectionName)
Check if a connection exists for the connector by the same connection name
|
void |
createConnection(String connector,
String connectionName,
Connection connection)
Stores a new single connection
|
void |
createConnection(String connector,
String connectionName,
ConnectionFactory factory,
Configuration configuration)
Creates a new connection pool and stores the connection
|
Connection |
getConnection(String connector,
String connectionName)
Retrieve connection by connector name and connection name
|
static ConnectionHandler |
getConnectionHandler()
Gets the Connection Handler instance
|
void |
returnConnection(String connector,
String connectionName,
Connection connection)
Return borrowed connection
|
void |
shutdownConnections()
Shutdown all the connection pools
|
void |
shutdownConnections(String connector)
Shutdown connection pools for a specified connector
|
public static ConnectionHandler getConnectionHandler()
public void createConnection(String connector, String connectionName, ConnectionFactory factory, Configuration configuration)
connector
- Name of the connectorconnectionName
- Name of the connectionfactory
- Connection Factory that defines how to create connectionsconfiguration
- Configurations for the connection poolpublic void createConnection(String connector, String connectionName, Connection connection)
connector
- Name of the connectorconnectionName
- Name of the connectionconnection
- Connection to be storedpublic Connection getConnection(String connector, String connectionName) throws ConnectException
connector
- Name of the connectorconnectionName
- Name of the connectionConnectException
- if failed to get connectionpublic void returnConnection(String connector, String connectionName, Connection connection)
connector
- Name of the connectorconnectionName
- Name of the connectionconnection
- Connection to be returned to the poolpublic void shutdownConnections()
public void shutdownConnections(String connector)
connector
- Name of the connectorpublic boolean checkIfConnectionExists(String connector, String connectionName)
connector
- Name of the connectorconnectionName
- Name of the connectionCopyright © 2020 WSO2. All rights reserved.