Interface DataSourceManager
public interface DataSourceManager
Manager for persistence resources such as DataSources and EntityManagerFactories. This interface provides methods to
obtain DataSources based on connection properties, retrieve EntityManagerFactories, and manage the lifecycle of
connections.
- Since:
- 8.5.0
- Author:
- Norman Lorenz
-
Method Summary
Modifier and TypeMethodDescriptionvoidCloses all managed connections and releases associated resources.voidcloseConnection(ConnectionIdentifier connectionIdentifier) Closes the connection associated with the given connection identifier.getDataSource(ConnectionProperties connectionProperties) Retrieves a DataSource based on the provided connection properties.getDataSourceInfo(ConnectionProperties connectionProperties) static DataSourceManagerRetrieves the singleton instance of thetestConnection(ConnectionProperties connectionProperties) Tests the database connection with TLS using the provided connection test parameters.
-
Method Details
-
getInstance
Retrieves the singleton instance of the- Returns:
- the singleton instance of
DataSourceManager - Throws:
IllegalStateException- if the CDI container is not available or the bean cannot be found
-
closeAllConnections
void closeAllConnections()Closes all managed connections and releases associated resources. This method should be called during application shutdown to ensure proper cleanup. -
closeConnection
Closes the connection associated with the given connection identifier. This method should be called to release resources when the connection is no longer needed.- Parameters:
connectionIdentifier- the identifier of the connection to be closed
-
getDataSource
Retrieves a DataSource based on the provided connection properties. The returned DataSource is managed by this manager (and underlying connection pool) and should not be closed by the caller.- Parameters:
connectionProperties- the properties used to configure the DataSource- Returns:
- a DataSource configured with the given connection properties
- Throws:
IllegalArgumentException- if the connection properties are invalidIllegalStateException- if the DataSource cannot be createdFcDriverException- if there is an error related to the database driverFcPersistenceException
-
getDataSourceInfo
IDataSourceInfo getDataSourceInfo(ConnectionProperties connectionProperties) throws FcPersistenceException - Throws:
FcPersistenceException
-
testConnection
ConnectionTestResult testConnection(ConnectionProperties connectionProperties) throws FcPersistenceException Tests the database connection with TLS using the provided connection test parameters.- Parameters:
connectionProperties- the connection test parameters- Returns:
- the result of the connection test, including trust validation results and any exceptions
- Throws:
IllegalArgumentException- if connectionTestParams is null or invalidFcDriverException- if no suitable JDBC driver is foundFcPersistenceException
-