Package io.nflow.engine.config.db
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 Summary
Fields Modifier and Type Field Description static StringNFLOW_DATABASE_INITIALIZERName of the nFlow database initializer bean.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDatabaseConfiguration(String dbType)Creates a new configuration with given database type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckDatabaseConfiguration(Environment env, DataSource dataSource)Checks that the database is configured as nFlow expects.DatabaseInitializernflowDatabaseInitializer(DataSource dataSource, Environment env)Creates the nFlow database initializer.DataSourcenflowDatasource(Environment env, Object metricRegistry)DataSourcenflowDatasource(Environment env, BeanFactory appCtx)Creates the datasource bean for nFlow.JdbcTemplatenflowJdbcTemplate(DataSource nflowDataSource)Creates a JDBC template using nFlow datasource.NamedParameterJdbcTemplatenflowNamedParameterJdbcTemplate(DataSource nflowDataSource)Creates a named parameter JDBC template using nFlow datasource.TransactionTemplatenflowTransactionTemplate(PlatformTransactionManager platformTransactionManager)Creates a transaction template.protected Stringproperty(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.protected <T> Tproperty(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.abstract SQLVariantssqlVariants(Environment env)Creates the SQL variants for the database.
-
-
-
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.
-
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.
-
-