@Override protected String getPropertyValue(FeatureState featureState, FeatureUser user, String name) { return ConfigResolver.getProjectStageAwarePropertyValue(name); } }
/** * {@inheritDoc} */ @Override protected String getConfiguredValue(String key) { return ConfigResolver.getProjectStageAwarePropertyValue(key); } }
/** * {@inheritDoc} */ @Override protected String getConfiguredValue(String key) { return ConfigResolver.getProjectStageAwarePropertyValue(key); } }
protected String getConfiguredValue(String key) { return ConfigResolver.getProjectStageAwarePropertyValue(key); }
/** * @param propertyName the name of the property key * @param defaultValue the default value to return if no configured property is found or * {@link ConfigProperty#NULL} if no default value should be returned. * @return the configured value or the defaultValue according to the NULL logic. */ protected String getPropertyValue(String propertyName, String defaultValue) { String configuredValue; if (ConfigProperty.NULL.equals(defaultValue)) { // no special defaultValue has been configured configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName); } else { configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName, defaultValue); } return configuredValue; }
/** * @param propertyName the name of the property key * @param defaultValue the default value to return if no configured property is found or * {@link ConfigProperty#NULL} if no default value should be returned. * @return the configured value or the defaultValue according to the NULL logic. */ protected String getPropertyValue(String propertyName, String defaultValue) { String configuredValue; if (ConfigProperty.NULL.equals(defaultValue)) { // no special defaultValue has been configured configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName); } else { configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName, defaultValue); } return configuredValue; }
/** * @param propertyName the name of the property key * @param defaultValue the default value to return if no configured property is found or * {@link ConfigProperty#NULL} if no default value should be returned. * @return the configured value or the defaultValue according to the NULL logic. */ protected String getPropertyValue(String propertyName, String defaultValue) { String configuredValue; if (ConfigProperty.NULL.equals(defaultValue)) { // no special defaultValue has been configured configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName); } else { configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName, defaultValue); } return configuredValue; }
String propertyValue = getProjectStageAwarePropertyValue(property); value = getProjectStageAwarePropertyValue(key + '.' + propertyValue); value = getProjectStageAwarePropertyValue(key);
public static Properties getTestContainerConfig() { String cdiTestRunnerConfig = ConfigResolver.getProjectStageAwarePropertyValue( CUSTOM_TEST_CONTAINER_CONFIG_FILE_KEY, DEFAULT_TEST_CONTAINER_CONFIG_FILE_NAME); return PropertyLoader.getProperties(cdiTestRunnerConfig); }
private String evaluateExpression(Scheduled scheduled) { String expression = scheduled.cronExpression(); if (expression.startsWith("{") && expression.endsWith("}")) { String configKey = expression.substring(1, expression.length() - 1); expression = ConfigResolver.getProjectStageAwarePropertyValue(configKey, null); if (expression == null) { throw new IllegalStateException("No config-value found for config-key: " + configKey); } } return expression; }
/** * {@link #getProjectStageAwarePropertyValue(String)} which returns the defaultValue * if the property is <code>null</code> or empty. * @param key * @param defaultValue * @return the configured value or if non found the defaultValue * */ public static String getProjectStageAwarePropertyValue(String key, String defaultValue) { String value = getProjectStageAwarePropertyValue(key); return fallbackToDefaultIfEmpty(key, value, defaultValue); }
/** * Load additional configuration from the Configuration system * and overload the basic settings with that info. * * The key is deltaspike.persistence.config.${persistenceUnitName}.${originalKey} * * @see #CONFIG_PREFIX * @since 1.8.0 */ protected Properties addConfigProperties(Properties unitProperties, String persistenceUnitName) { // we start with a copy of the original properties Properties mergedConfig = new Properties(); mergedConfig.putAll(unitProperties); Set<String> allConfigKeys = ConfigResolver.getAllProperties().keySet(); String unitPrefix = CONFIG_PREFIX + persistenceUnitName + "."; for (String configKey : allConfigKeys) { if (configKey.startsWith(unitPrefix)) { mergedConfig.put(configKey.substring(unitPrefix.length()), ConfigResolver.getProjectStageAwarePropertyValue(configKey)); } } return mergedConfig; } }
private List<ConfigEntry> calculateConfigEntries() { Map<String, String> allProperties = ConfigResolver.getAllProperties(); List<ConfigEntry> configEntries = new ArrayList<ConfigEntry>(allProperties.size()); ConfigSource[] configSources = ConfigResolver.getConfigSources(); for (Map.Entry<String, String> configEntry : allProperties.entrySet()) { String key = configEntry.getKey(); String value = ConfigResolver.filterConfigValueForLog(key, ConfigResolver.getProjectStageAwarePropertyValue(key)); String fromConfigSource = getFromConfigSource(configSources, key); configEntries.add(new ConfigEntry(key, value, fromConfigSource)); } return configEntries; }
ConfigResolver.getProjectStageAwarePropertyValue(classFilterClassName, classFilterClassName);
@Test public void testProjectStageAwarePropertyValueReference_1() { final String expectedFooUrl = "http://bar-dev/services"; final String actualFooUrl = ConfigResolver.getProjectStageAwarePropertyValue( "foo.url"); Assert.assertEquals(expectedFooUrl, actualFooUrl); }
@Test public void testProjectStageAwarePropertyValueReference_2() { final String expected = "projectStageAware-exampleEntry-1-is-tomato-UnitTest"; final String projectStageAwareExampleEntry1 = ConfigResolver.getProjectStageAwarePropertyValue( "deltaspike.test.exampleEntry-2", ""); Assert.assertEquals(expected, projectStageAwareExampleEntry1); }
@Test public void testGetProjectStageAwarePropertyValue() { ProjectStageProducer.setProjectStage(ProjectStage.UnitTest); Assert.assertNull(ConfigResolver.getProjectStageAwarePropertyValue("notexisting", null)); Assert.assertEquals("testvalue", ConfigResolver.getPropertyValue("testkey")); Assert.assertEquals("unittestvalue", ConfigResolver.getProjectStageAwarePropertyValue("testkey")); Assert.assertEquals("unittestvalue", ConfigResolver.getProjectStageAwarePropertyValue("testkey", null)); Assert.assertEquals("testvalue", ConfigResolver.getPropertyValue("testkey2")); Assert.assertEquals("testvalue", ConfigResolver.getProjectStageAwarePropertyValue("testkey2")); Assert.assertEquals("testvalue", ConfigResolver.getProjectStageAwarePropertyValue("testkey2", null)); Assert.assertEquals("testvalue", ConfigResolver.getPropertyValue("testkey3")); Assert.assertEquals("", ConfigResolver.getProjectStageAwarePropertyValue("testkey3")); Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.getProjectStageAwarePropertyValue("testkey3", DEFAULT_VALUE)); Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.getProjectStageAwarePropertyValue("deltaspike.test.projectstagefallback", DEFAULT_VALUE)); Assert.assertEquals("", ConfigResolver.getProjectStageAwarePropertyValue("deltaspike.test.projectstagefallback")); Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.resolve("deltaspike.test.projectstagefallback").as(String.class).withDefault(DEFAULT_VALUE).withCurrentProjectStage(true).getValue()); Assert.assertEquals("", ConfigResolver.resolve("deltaspike.test.projectstagefallback").as(String.class).withCurrentProjectStage(true).getValue()); }
@Test public void testConfigFilter() { ConfigFilter configFilter = new TestConfigFilter(); Assert.assertEquals("shouldGetDecrypted: value", configFilter.filterValue("somekey.encrypted", "value")); Assert.assertEquals("**********", configFilter.filterValueForLog("somekey.password", "value")); ConfigResolver.addConfigFilter(configFilter); Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyValue("testkey4.encrypted")); Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted")); Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted", null)); Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor")); Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor", null)); List<String> allPropertyValues = ConfigResolver.getAllPropertyValues("testkey4.encrypted"); Assert.assertNotNull(allPropertyValues); Assert.assertEquals(1, allPropertyValues.size()); Assert.assertEquals("shouldGetDecrypted: value", allPropertyValues.get(0)); }