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
Base class for different database configurations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the nFlow database initializer bean. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDatabaseConfiguration(String dbType) Creates a new configuration with given database type. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckDatabaseConfiguration(Environment env, DataSource dataSource) Checks that the database is configured as nFlow expects.Return the type of the database.nflowDatabaseInitializer(DataSource dataSource, Environment env) Creates the nFlow database initializer.nflowDatasource(Environment env, Object metricRegistry) nflowDatasource(Environment env, BeanFactory appCtx) Creates the datasource bean for nFlow.nflowJdbcTemplate(DataSource nflowDataSource) Creates a JDBC template using nFlow datasource.nflowNamedParameterJdbcTemplate(DataSource nflowDataSource) Creates a named parameter JDBC template using nFlow datasource.nflowTransactionTemplate(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 Details
-
NFLOW_DATABASE_INITIALIZER
Name of the nFlow database initializer bean.- See Also:
-
-
Constructor Details
-
DatabaseConfiguration
Creates a new configuration with given database type.- Parameters:
dbType- Defines the database creation script and configuration properties to be used.
-
-
Method Details
-
getDbType
Return the type of the database.- Returns:
- Type of the database.
-
nflowDatasource
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
-
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
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
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
Checks that the database is configured as nFlow expects.- Parameters:
env- The Spring environment.dataSource- The nFlow datasource.
-
sqlVariants
Creates the SQL variants for the database.- Parameters:
env- The Spring environment.- Returns:
- SQL variants optimized for the database.
-