Search in sources :

Example 6 with ConfigKey

use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.

the class NetworkConfigurer method fixSocketBindings.

protected void fixSocketBindings(SocketBindingGroup group) {
    ConfigKey key = ROOT.append(group.name()).append("socket-bindings");
    List<SimpleKey> names = this.configView.simpleSubkeys(key);
    names.stream().map(e -> e.name()).map(name -> group.socketBindings().stream().filter(e -> e.name().equals(name)).findFirst().orElseGet(() -> {
        SocketBinding binding = new SocketBinding(name);
        group.socketBinding(binding);
        return binding;
    })).forEach(e -> {
        applyConfiguration(key, e);
    });
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Consumer(java.util.function.Consumer) Inject(javax.inject.Inject) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) List(java.util.List) Interface(org.wildfly.swarm.container.Interface) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Any(javax.enterprise.inject.Any) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Instance(javax.enterprise.inject.Instance) SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Example 7 with ConfigKey

use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.

the class NetworkConfigurer method applyConfiguration.

protected void applyConfiguration(ConfigKey root, OutboundSocketBinding binding) {
    ConfigKey key = root.append(binding.name());
    applyConfiguration(key.append("remote-host"), (host) -> {
        binding.remoteHost(host.toString());
    });
    applyConfiguration(key.append("remote-port"), (port) -> {
        binding.remotePort(port.toString());
    });
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey)

Example 8 with ConfigKey

use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.

the class NetworkConfigurer method fixGroup.

protected void fixGroup(SocketBindingGroup group) {
    ConfigKey key = ROOT.append(group.name());
    int offset = this.configView.resolve(SWARM.append("port", "offset")).as(Integer.class).withDefault(0).getValue();
    group.portOffset(offset);
    applyConfiguration(key.append("port-offset"), (portOffset) -> {
        group.portOffset(portOffset.toString());
    });
    applyConfiguration(key.append("default-interface"), (defaultInterface) -> {
        group.defaultInterface(defaultInterface.toString());
    });
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey)

Example 9 with ConfigKey

use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.

the class NetworkConfigurer method fixOutboundSocketBindings.

protected void fixOutboundSocketBindings(SocketBindingGroup group) {
    ConfigKey key = ROOT.append(group.name()).append("outbound-socket-bindings");
    List<SimpleKey> names = this.configView.simpleSubkeys(key);
    names.stream().map(e -> e.name()).map(name -> group.outboundSocketBindings().stream().filter(e -> e.name().equals(name)).findFirst().orElseGet(() -> {
        OutboundSocketBinding binding = new OutboundSocketBinding(name);
        group.outboundSocketBinding(binding);
        return binding;
    })).forEach(e -> {
        applyConfiguration(key, e);
    });
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Consumer(java.util.function.Consumer) Inject(javax.inject.Inject) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) List(java.util.List) Interface(org.wildfly.swarm.container.Interface) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Any(javax.enterprise.inject.Any) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Instance(javax.enterprise.inject.Instance) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Example 10 with ConfigKey

use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.

the class SocketBindingGroupExtension method applyConfiguration.

@Override
protected void applyConfiguration(SocketBindingGroup instance) {
    ConfigKey key = ROOT.append(instance.name());
    applyConfiguration(key.append("port-offset"), (offset) -> {
        instance.portOffset(offset.toString());
    });
    applyConfiguration(key.append("default-interface"), (offset) -> {
        instance.portOffset(offset.toString());
    });
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey)

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