Search in sources :

Example 1 with SocketBinding

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

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

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

the class ManagementSocketBindingsCustomizer method customize.

public void customize() {
    this.group.socketBinding(new SocketBinding("management-http").iface(iface.get()).port(fraction.httpPort()));
    this.group.socketBinding(new SocketBinding("management-https").port(fraction.httpsPort()));
    if (fraction.isHttpDisable()) {
        fraction.httpInterfaceManagementInterface((HTTPInterfaceManagementInterface<?>) null);
    }
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding)

Example 4 with SocketBinding

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

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

SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)8 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)5 Test (org.junit.Test)3 OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)3 UndertowFraction (org.wildfly.swarm.undertow.UndertowFraction)3 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Any (javax.enterprise.inject.Any)1 Instance (javax.enterprise.inject.Instance)1 Inject (javax.inject.Inject)1 PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 ValueExpression (org.jboss.dmr.ValueExpression)1 Interface (org.wildfly.swarm.container.Interface)1 ConfigKey (org.wildfly.swarm.spi.api.config.ConfigKey)1 ConfigView (org.wildfly.swarm.spi.api.config.ConfigView)1 SimpleKey (org.wildfly.swarm.spi.api.config.SimpleKey)1