Search in sources :

Example 21 with ConfigKey

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);
    }
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey)

Example 22 with ConfigKey

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");
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) Test(org.junit.Test)

Example 23 with ConfigKey

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();
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) Test(org.junit.Test)

Example 24 with ConfigKey

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);
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) Test(org.junit.Test)

Example 25 with ConfigKey

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);
        }
    });
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationManager(com.netflix.config.ConfigurationManager) Set(java.util.Set) Customizer(org.wildfly.swarm.spi.api.Customizer) Post(org.wildfly.swarm.spi.runtime.annotations.Post) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ConfigurableHandle(org.wildfly.swarm.container.runtime.ConfigurableHandle) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurableManager(org.wildfly.swarm.container.runtime.ConfigurableManager) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) PostConstruct(javax.annotation.PostConstruct) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Any(javax.enterprise.inject.Any) Instance(javax.enterprise.inject.Instance) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) HashSet(java.util.HashSet)

Aggregations

ConfigKey (org.wildfly.swarm.spi.api.config.ConfigKey)26 SimpleKey (org.wildfly.swarm.spi.api.config.SimpleKey)7 Test (org.junit.Test)6 List (java.util.List)4 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Any (javax.enterprise.inject.Any)3 Instance (javax.enterprise.inject.Instance)3 Inject (javax.inject.Inject)3 Field (java.lang.reflect.Field)2 HashSet (java.util.HashSet)2 Consumer (java.util.function.Consumer)2 Interface (org.wildfly.swarm.container.Interface)2 OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)2 SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)2 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)2 Configurable (org.wildfly.swarm.spi.api.annotations.Configurable)2 ConfigView (org.wildfly.swarm.spi.api.config.ConfigView)2 ConfigurationManager (com.netflix.config.ConfigurationManager)1