Class TableManager
java.lang.Object
de.aristaflow.adept2.base.registry.dbconfiguration.TableManager
- All Implemented Interfaces:
EventListener<ConfigurationEvent>
This class creates and drops tables for a
A table is created as soon as the corresponding configuration gets a value and it will be removed as soon as the table is cleared.
DatabaseConfiguration. This way there are no
superfluous tables for runtime configurations. A table is created as soon as the corresponding configuration gets a value and it will be removed as soon as the table is cleared.
This implementation creates tables having 50 characters for the key and 1000 characters for the value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final JDBCDataSourceThe data source storing the runtime configuration table.protected final StringThe name of the column for the keys of the runtime configuration.protected final LoggerThe logger for problems creating or dropping the table.protected booleanWhether the table for the runtime configuration exists.protected final StringThe name of the table for the runtime configuration.protected final StringThe name of the column for the values of the runtime configuration. -
Constructor Summary
ConstructorsConstructorDescriptionTableManager(Logger logger, JDBCDataSource dataSource, String tableName, String keyColumn, String valueColumn) Creates a new listener that creates and drops tables for runtime configurations. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateOrUpdateTable(boolean create) Creates or updates the table for the runtime configuration.protected voidDrops the table for the runtime configuration.voidonEvent(ConfigurationEvent event)
-
Field Details
-
logger
The logger for problems creating or dropping the table. -
dataSource
The data source storing the runtime configuration table. -
tableName
The name of the table for the runtime configuration. -
keyColumn
The name of the column for the keys of the runtime configuration. -
valueColumn
The name of the column for the values of the runtime configuration. -
tableExists
protected boolean tableExistsWhether the table for the runtime configuration exists.
-
-
Constructor Details
-
TableManager
public TableManager(Logger logger, JDBCDataSource dataSource, String tableName, String keyColumn, String valueColumn) throws SQLException Creates a new listener that creates and drops tables for runtime configurations. The constructor checks whether the table already exists.- Parameters:
logger- The logger for problems creating or dropping the table.dataSource- The data source storing the runtime configuration table.tableName- The name of the table for the runtime configuration.keyColumn- The name of the column for the keys of the runtime configuration.valueColumn- The name of the column for the values of the runtime configuration.- Throws:
SQLException- If detecting whether the table exists or not fails, anSQLExceptionwill be thrown.
-
-
Method Details
-
createOrUpdateTable
protected void createOrUpdateTable(boolean create) Creates or updates the table for the runtime configuration. Creating only applies the initial update.- Parameters:
create- Whether to create the table (instead of updating).
-
dropTable
protected void dropTable()Drops the table for the runtime configuration. -
onEvent
- Specified by:
onEventin interfaceEventListener<ConfigurationEvent>
-