use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class PropertiesConfigNodeFactory method load.
protected static void load(ConfigNode config, Properties input) {
Enumeration<?> names = input.propertyNames();
while (names.hasMoreElements()) {
String propName = names.nextElement().toString();
String propValue = input.getProperty(propName);
ConfigKey key = ConfigKey.parse(propName);
config.recursiveChild(key, propValue);
}
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigKeyTest method testSeveralSegmentsNoInternalDots.
@Test
public void testSeveralSegmentsNoInternalDots() {
ConfigKey key = ConfigKey.parse("[foo].[bar].[baz]");
assertThat(key.head().name()).isEqualTo("foo");
assertThat(key.subkey(1).head().name()).isEqualTo("bar");
assertThat(key.subkey(2).head().name()).isEqualTo("baz");
assertThat(key.subkey(3).head()).isEqualTo(ConfigKey.EMPTY);
assertThat(key.name()).isEqualTo("foo.bar.baz");
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigKeyTest method testParentage.
@Test
public void testParentage() {
ConfigKey child = ConfigKey.parse("swarm.deployment.*.foo");
ConfigKey parent = ConfigKey.parse("swarm.deployment.*");
ConfigKey cousin = ConfigKey.parse("swarm.deployment.tacos");
assertThat(child.isChildOf(parent)).isTrue();
assertThat(parent.isChildOf(child)).isFalse();
assertThat(cousin.isChildOf(child)).isFalse();
assertThat(child.isChildOf(cousin)).isFalse();
assertThat(cousin.isChildOf(parent)).isFalse();
assertThat(parent.isChildOf(parent)).isFalse();
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigKeyTest method testParseWithOnlyDots.
@Test
public void testParseWithOnlyDots() {
ConfigKey key = ConfigKey.parse("foo.bar.baz");
assertThat(key.head().name()).isEqualTo("foo");
assertThat(key.subkey(1).head().name()).isEqualTo("bar");
assertThat(key.subkey(2).head().name()).isEqualTo("baz");
assertThat(key.subkey(3).head()).isEqualTo(ConfigKey.EMPTY);
assertThat(key.name()).isEqualTo("foo.bar.baz");
assertThat(key).isInstanceOf(CompositeKey.class);
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ArchaiusCustomizer method customize.
@Override
public void customize() {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
Set<ConfigKey> seen = new HashSet<>();
this.configurableManager.configurables().stream().filter(this::shouldLink).forEach(e -> {
try {
Object value = e.currentValue();
if (value != null) {
config.setProperty(e.key().subkey(1).name(), e.currentValue());
}
seen.add(e.key());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
this.configurableManager.configView().allKeysRecursively().filter(this::shouldLink).filter(k -> !seen.contains(k)).forEach(k -> {
Object value = this.configurableManager.configView().valueOf(k);
if (value != null) {
config.setProperty(k.subkey(1).name(), value);
}
});
}
Aggregations