protected void init() { LinkedHashMap<String,Properties> propertiesByEnvironment = new LinkedHashMap<>(); // fetch properties for each specific environment environments.forEach(currentEnvironment -> { DatabaseConfiguration dbConfig = createDatabaseConfiguration(this.dataSource,this.tableName,this.environmentColumn,this.propertyKeyColumn,this.valueColumn,currentEnvironment); propertiesByEnvironment.put(PROPERTY_SOURCE_PREFIX + "-" + currentEnvironment, createPropertiesForConfiguration(dbConfig)); }); // fetch default properties DatabaseConfiguration dbConfigDefault = createDatabaseConfiguration(this.dataSource,this.tableName,this.environmentColumn,this.propertyKeyColumn,this.valueColumn,this.defaultEnvironment); propertiesByEnvironment.put(PROPERTY_SOURCE_PREFIX + "-" + PROPERTY_SOURCE_DEFAULT, createPropertiesForConfiguration(dbConfigDefault)); this.properties = new OrderedProperties(propertiesByEnvironment); }
private ConfigurationHelper(String applicationContextName) { DataSource ds = getDataSourceForContext(applicationContextName); DatabaseConfiguration config = new DatabaseConfiguration(ds, TABLE_NAME, KEY_COLUMN, VALUE_COLUMN); ConfigurationListener listener = new LockoutConfigurationListener(); config.addConfigurationListener(listener); config.addErrorListener((ConfigurationErrorListener) listener); config.setDelimiterParsingDisabled(true); dataConfig = new DataConfiguration(config); }
/** * @return the system configuration. */ public static DataConfiguration getConfiguration() { DataSource ds = null; try { ds = (DataSource) ServiceLocatorFactory.getLocator().lookup(DATASOURCE_JNDI_LOC); if (ds == null) { ds = getAdhocDataSource(); } } catch (IllegalStateException e) { ds = getAdhocDataSource(); } DatabaseConfiguration config = new DatabaseConfiguration(ds, TABLE_NAME, PARAM_NAME_COLUMN, PARAM_VALUE_COLUMN); config.setDelimiterParsingDisabled(true); return new DataConfiguration(config); }
@Bean public DatabaseConfiguration mallConfig() { return new DefaultDatabaseConfiguration(dataSource, "mall", "商城配置"); }
@Bean public DatabaseConfiguration mainConfig() { return new DefaultDatabaseConfiguration(dataSource, "main", "基础配置"); }
private DataConfiguration getConfiguration() { DatabaseConfiguration config = new DatabaseConfiguration(dataSource, TABLE_NAME, PARAM_NAME_COLUMN, PARAM_VALUE_COLUMN); config.setDelimiterParsingDisabled(true); return new DataConfiguration(config); }
/** * Creates a DatabaseConfiguration instance with the specified parameters. * * @param dataSource the data-source * @param tableName the table name * @param environmentColumn the environment column * @param keyColumn the key column * @param valueColumn the value column * @param environment the environment * @return the DatabaseConfiguration instance */ protected DatabaseConfiguration createDatabaseConfiguration(DataSource dataSource, String tableName, String environmentColumn, String keyColumn, String valueColumn, String environment){ DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration(dataSource,tableName,environmentColumn,keyColumn,valueColumn,environment); databaseConfiguration.setDelimiterParsingDisabled(true); return databaseConfiguration; }
/** * Gets a database configuration that can be used to read database properties. * * @return the property database configuration. */ private static DatabaseConfiguration getPropertyDatabaseConfiguration() { return new DatabaseConfiguration(getHerdDataSource(), ConfigurationEntity.TABLE_NAME, ConfigurationEntity.COLUMN_KEY, ConfigurationEntity.COLUMN_VALUE); }