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 Details

    • 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 invalid
      IllegalStateException - if the DataSource cannot be created
      FcDriverException - if there is an error related to the database driver
      FcPersistenceException
    • 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 invalid
      FcDriverException - if no suitable JDBC driver is found
      FcPersistenceException