Class DatabaseConfiguration

    • Field Detail

      • NFLOW_DATABASE_INITIALIZER

        public static final String NFLOW_DATABASE_INITIALIZER
        Name of the nFlow database initializer bean.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DatabaseConfiguration

        protected DatabaseConfiguration​(String dbType)
        Creates a new configuration with given database type.
        Parameters:
        dbType - Defines the database creation script and configuration properties to be used.
    • Method Detail

      • nflowDatasource

        @Bean
        public DataSource nflowDatasource​(Environment env,
                                          BeanFactory appCtx)
        Creates the datasource bean for nFlow.
        Parameters:
        env - The Spring environment for getting the configuration property values.
        appCtx - The application context for searching Metrics registry bean.
        Returns:
        The datasource for nFlow.
      • nflowJdbcTemplate

        @Bean
        @Scope("prototype")
        @DependsOn("nflowDatabaseInitializer")
        public JdbcTemplate nflowJdbcTemplate​(DataSource nflowDataSource)
        Creates a JDBC template using nFlow datasource.
        Parameters:
        nflowDataSource - The nFlow datasource.
        Returns:
        A JDBC template.
      • nflowNamedParameterJdbcTemplate

        @Bean
        @Scope("prototype")
        @DependsOn("nflowDatabaseInitializer")
        public NamedParameterJdbcTemplate nflowNamedParameterJdbcTemplate​(DataSource nflowDataSource)
        Creates a named parameter JDBC template using nFlow datasource.
        Parameters:
        nflowDataSource - The nFlow datasource.
        Returns:
        A named parameter JDBC template.
      • nflowTransactionTemplate

        @Bean
        public TransactionTemplate nflowTransactionTemplate​(PlatformTransactionManager platformTransactionManager)
        Creates a transaction template.
        Parameters:
        platformTransactionManager - Transaction manager to be used.
        Returns:
        A transaction template.
      • property

        protected String property​(Environment env,
                                  String key)
        Get a database configuration string property from the environment, or if the generic property is not defined, the property based on the database type.
        Parameters:
        env - The Spring environment.
        key - The property key.
        Returns:
        The property value.
      • property

        protected <T> T property​(Environment env,
                                 String key,
                                 Class<T> type)
        Get the database configuration property of given type from the environment, or if the generic property is not defined, the property based on the database type.
        Type Parameters:
        T - The Property value type.
        Parameters:
        env - The Spring environment.
        key - The property key.
        type - The property value type.
        Returns:
        The property value.
      • nflowDatabaseInitializer

        @Bean(name="nflowDatabaseInitializer")
        public DatabaseInitializer nflowDatabaseInitializer​(DataSource dataSource,
                                                            Environment env)
        Creates the nFlow database initializer.
        Parameters:
        dataSource - The nFlow datasource.
        env - The Spring environment.
        Returns:
        The database initializer.
      • checkDatabaseConfiguration

        protected void checkDatabaseConfiguration​(Environment env,
                                                  DataSource dataSource)
        Checks that the database is configured as nFlow expects.
        Parameters:
        env - The Spring environment.
        dataSource - The nFlow datasource.
      • sqlVariants

        public abstract SQLVariants sqlVariants​(Environment env)
        Creates the SQL variants for the database.
        Parameters:
        env - The Spring environment.
        Returns:
        SQL variants optimized for the database.