Search in sources :

Example 1 with SocketBindingGroup

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

the class UndertowSocketBindingsCustomizerTest method testDefaultPorts.

@Test
public void testDefaultPorts() {
    UndertowSocketBindingsCustomizer customizer = new UndertowSocketBindingsCustomizer();
    customizer.fraction = new UndertowFraction();
    customizer.group = new SocketBindingGroup("standard-sockets", "public", "0");
    customizer.customize();
    assertThat(customizer.group.socketBindings()).hasSize(2);
    SocketBinding http = customizer.group.socketBinding("http");
    assertThat(http).isNotNull();
    assertThat(http.portExpression()).isEqualTo("8080");
    SocketBinding https = customizer.group.socketBinding("https");
    assertThat(https).isNotNull();
    assertThat(https.portExpression()).isEqualTo("8443");
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) Test(org.junit.Test)

Example 2 with SocketBindingGroup

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

the class UndertowSocketBindingsCustomizerTest method testExplicitHttpsPort.

@Test
public void testExplicitHttpsPort() {
    UndertowSocketBindingsCustomizer customizer = new UndertowSocketBindingsCustomizer();
    customizer.fraction = new UndertowFraction();
    customizer.fraction.httpsPort(8675);
    customizer.group = new SocketBindingGroup("standard-sockets", "public", "0");
    customizer.customize();
    assertThat(customizer.group.socketBindings()).hasSize(2);
    SocketBinding http = customizer.group.socketBinding("http");
    assertThat(http).isNotNull();
    assertThat(http.portExpression()).isEqualTo("8080");
    SocketBinding https = customizer.group.socketBinding("https");
    assertThat(https).isNotNull();
    assertThat(https.portExpression()).isEqualTo("8675");
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) Test(org.junit.Test)

Example 3 with SocketBindingGroup

use of org.wildfly.swarm.spi.api.SocketBindingGroup 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 4 with SocketBindingGroup

use of org.wildfly.swarm.spi.api.SocketBindingGroup 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 5 with SocketBindingGroup

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

the class SocketBindingGroupMarshaller method marshal.

public void marshal(List<ModelNode> list) {
    for (SocketBindingGroup group : this.socketBindingGroups) {
        PathAddress address = PathAddress.pathAddress("socket-binding-group", group.name());
        ModelNode node = new ModelNode();
        node.get(OP).set(ADD);
        node.get(OP_ADDR).set(address.toModelNode());
        node.get(DEFAULT_INTERFACE).set(group.defaultInterface());
        node.get(PORT_OFFSET).set(new ValueExpression(group.portOffsetExpression()));
        LinkedList<ModelNode> subList = new LinkedList<>();
        subList.add(node);
        for (SocketBinding binding : group.socketBindings()) {
            configureSocketBinding(address, binding, subList);
        }
        for (OutboundSocketBinding binding : group.outboundSocketBindings()) {
            configureSocketBinding(address, binding, subList);
        }
        if (!isAlreadyConfigured(subList, list)) {
            list.addAll(subList);
        }
    }
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) PathAddress(org.jboss.as.controller.PathAddress) ValueExpression(org.jboss.dmr.ValueExpression) ModelNode(org.jboss.dmr.ModelNode) LinkedList(java.util.LinkedList)

Aggregations

SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)8 SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)6 List (java.util.List)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Test (org.junit.Test)3 OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)3 ConfigKey (org.wildfly.swarm.spi.api.config.ConfigKey)3 ConfigView (org.wildfly.swarm.spi.api.config.ConfigView)3 SimpleKey (org.wildfly.swarm.spi.api.config.SimpleKey)3 UndertowFraction (org.wildfly.swarm.undertow.UndertowFraction)3 Consumer (java.util.function.Consumer)2 Any (javax.enterprise.inject.Any)2 Instance (javax.enterprise.inject.Instance)2 Inject (javax.inject.Inject)2 Interface (org.wildfly.swarm.container.Interface)2 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Observes (javax.enterprise.event.Observes)1 AfterBeanDiscovery (javax.enterprise.inject.spi.AfterBeanDiscovery)1