Class DatabaseConfiguration

java.lang.Object
io.nflow.engine.config.db.DatabaseConfiguration
Direct Known Subclasses:
Db2DatabaseConfiguration, H2DatabaseConfiguration, MariadbDatabaseConfiguration, MysqlDatabaseConfiguration, OracleDatabaseConfiguration, PgDatabaseConfiguration, SqlServerDatabaseConfiguration

public abstract class DatabaseConfiguration extends Object
Base class for different database configurations.
  • Field Details

    • NFLOW_DATABASE_INITIALIZER

      public static final String NFLOW_DATABASE_INITIALIZER
      Name of the nFlow database initializer bean.
      See Also:
  • Constructor Details

    • 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 Details

    • getDbType

      public String getDbType()
      Return the type of the database.
      Returns:
      Type of the database.
    • 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.
    • nflowDatasource

      public DataSource nflowDatasource(Environment env, Object metricRegistry)
    • 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.