public class TableManager extends java.lang.Object implements EventListener<ConfigurationEvent>
DatabaseConfiguration. This way there are no
superfluous tables for runtime configurations. This implementation creates tables having 50 characters for the key and 1000 characters for the value.
| Modifier and Type | Field and Description |
|---|---|
protected JDBCDataSource |
dataSource
The data source storing the runtime configuration table.
|
protected java.lang.String |
keyColumn
The name of the column for the keys of the runtime configuration.
|
protected java.util.logging.Logger |
logger
The logger for problems creating or dropping the table.
|
protected boolean |
tableExists
Whether the table for the runtime configuration exists.
|
protected java.lang.String |
tableName
The name of the table for the runtime configuration.
|
protected java.lang.String |
valueColumn
The name of the column for the values of the runtime configuration.
|
| Constructor and Description |
|---|
TableManager(java.util.logging.Logger logger,
JDBCDataSource dataSource,
java.lang.String tableName,
java.lang.String keyColumn,
java.lang.String valueColumn)
Creates a new listener that creates and drops tables for runtime
configurations.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
createOrUpdateTable(boolean create)
Creates or updates the table for the runtime configuration.
|
protected void |
dropTable()
Drops the table for the runtime configuration.
|
void |
onEvent(ConfigurationEvent event) |
protected final java.util.logging.Logger logger
protected final JDBCDataSource dataSource
protected final java.lang.String tableName
protected final java.lang.String keyColumn
protected final java.lang.String valueColumn
protected boolean tableExists
public TableManager(java.util.logging.Logger logger,
JDBCDataSource dataSource,
java.lang.String tableName,
java.lang.String keyColumn,
java.lang.String valueColumn)
throws java.sql.SQLException
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.java.sql.SQLException - If detecting whether the table exists or not fails, an
SQLException will be thrown.protected void createOrUpdateTable(boolean create)
create - Whether to create the table (instead of updating).protected void dropTable()
public void onEvent(ConfigurationEvent event)
onEvent in interface EventListener<ConfigurationEvent>