Package de.xima.fc.persistence
Interface DataSourceManager
-
public interface DataSourceManagerManager 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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcloseAllConnections()Closes all managed connections and releases associated resources.voidcloseConnection(ConnectionIdentifier connectionIdentifier)Closes the connection associated with the given connection identifier.DataSourcegetDataSource(ConnectionProperties connectionProperties)Retrieves a DataSource based on the provided connection properties.IDataSourceInfogetDataSourceInfo(ConnectionProperties connectionProperties)static DataSourceManagergetInstance()Retrieves the singleton instance of theConnectionTestResulttestConnection(ConnectionProperties connectionProperties)Tests the database connection with TLS using the provided connection test parameters.
-
-
-
Method Detail
-
getInstance
static DataSourceManager 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
void closeConnection(ConnectionIdentifier connectionIdentifier)
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
DataSource getDataSource(ConnectionProperties connectionProperties) throws FcPersistenceException
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
-
-