Class ConnectionHandler
- java.lang.Object
-
- org.wso2.carbon.connector.core.connection.ConnectionHandler
-
- All Implemented Interfaces:
LocalEntryUndeployCallBack
public class ConnectionHandler extends Object implements LocalEntryUndeployCallBack
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, Connection connection, org.apache.synapse.MessageContext messageContext)
Stores a new single connectionvoid
createConnection(String connector, String connectionName, ConnectionFactory factory, Configuration configuration)
Creates a new connection pool and stores the connectionvoid
createConnection(String connector, String connectionName, ConnectionFactory factory, Configuration configuration, org.apache.synapse.MessageContext messageContext)
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
initializeLocalEntryConnectionMapping(String connector, String connectionName, org.apache.synapse.MessageContext messageContext)
Initialize local entry connection mappingvoid
onLocalEntryUndeploy(String localEntryKey)
Listen for local entry un deploy events and cleanup connections originated by that local entry.void
removeLocalEntryConnections(String localEntryName)
remove local entry and associate connections from local entry store and connection mapvoid
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
-
initializeLocalEntryConnectionMapping
public void initializeLocalEntryConnectionMapping(String connector, String connectionName, org.apache.synapse.MessageContext messageContext)
Initialize local entry connection mapping- Parameters:
connector
- Name of the connectorconnectionName
- Name of the connectionmessageContext
- Message Context
-
onLocalEntryUndeploy
public void onLocalEntryUndeploy(String localEntryKey)
Description copied from interface:LocalEntryUndeployCallBack
Listen for local entry un deploy events and cleanup connections originated by that local entry.- Specified by:
onLocalEntryUndeploy
in interfaceLocalEntryUndeployCallBack
-
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 connectorconnectionName
- Name of the connectionfactory
- Connection Factory that defines how to create connectionsconfiguration
- Configurations for the connection poolmessageContext
- 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 connectorconnectionName
- Name of the connectionconnection
- Connection to be storedmessageContext
- 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 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
-
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 connectorconnectionName
- Name of the connection- Returns:
- true if a connection exists, false otherwise
-
-