Class AweDatabaseContextHolder

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    public class AweDatabaseContextHolder
    extends ServiceConfig
    Author:
    pgarcia
    • Constructor Detail

      • AweDatabaseContextHolder

        public AweDatabaseContextHolder​(AweElements elements,
                                        QueryService queryService,
                                        SessionService sessionService,
                                        org.springframework.boot.autoconfigure.jdbc.DataSourceProperties dataSourceProperties,
                                        DatabaseConfigProperties databaseConfigProperties)
        Autowired constructor
        Parameters:
        queryService - Query service
        sessionService - Session Service
        dataSourceProperties - DataSource properties
        databaseConfigProperties - Database config properties
    • Method Detail

      • getDataSources

        public Map<Object,​Object> getDataSources()
        Load dataSources from current connection
        Returns:
        datasource map
      • getDefaultDataSource

        public DataSource getDefaultDataSource()
        Get the default datasource
        Returns:
        Datasource connection
      • getDatabaseType

        public String getDatabaseType​(DataSource dataSource)
                               throws AWException
        Get current connection type
        Returns:
        Database type
        Throws:
        AWException - Error retrieving database type
      • getCurrentDatabase

        public String getCurrentDatabase()
        Get current database
        Returns:
        Current database
      • getDatabaseConnection

        public DatabaseConnection getDatabaseConnection​(DataSource dataSource)
                                                 throws AWException
        Get current database connection
        Parameters:
        dataSource - datasource
        Returns:
        Database connection
        Throws:
        AWException - error retrieving connection or database type
      • getDatabaseConnection

        public DatabaseConnection getDatabaseConnection​(String alias)
                                                 throws AWException
        Get current database connection
        Parameters:
        alias - Datasource alias
        Returns:
        Database connection
        Throws:
        AWException - error retrieving connection or database type