Search in sources :

Example 6 with SocketBinding

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

the class NetworkVariableSupplier method valueOf.

protected Object valueOf(SocketBindingGroup group, String name) throws Exception {
    String[] parts = name.split("\\.");
    String bindingName = null;
    String which = "port";
    if (parts.length == 3) {
        bindingName = parts[1];
    } else if (parts.length == 4) {
        bindingName = parts[1];
        which = parts[2];
    }
    int offset = Integer.parseInt(group.portOffsetExpression());
    for (SocketBinding socketBinding : group.socketBindings()) {
        if (socketBinding.name().equals(bindingName)) {
            if (which.equals("port")) {
                int port = Integer.parseInt(socketBinding.portExpression());
                return "" + (port + offset);
            } else if (which.equals("multicast-port")) {
                int port = Integer.parseInt(socketBinding.multicastPortExpression());
                return "" + (port + offset);
            } else if (which.equals("multicast-address")) {
                String addr = socketBinding.multicastAddress();
                return addr;
            } else if (which.equals("host")) {
                return valueOf("swarm." + socketBinding.iface() + ".host");
            }
        }
    }
    return null;
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding)

Example 7 with SocketBinding

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

the class SocketBindingGroupMarshaller method configureSocketBindings.

private void configureSocketBindings(PathAddress address, SocketBindingGroup group, List<ModelNode> list) {
    List<SocketBinding> socketBindings = group.socketBindings();
    for (SocketBinding each : socketBindings) {
        configureSocketBinding(address, each, list);
    }
    List<OutboundSocketBinding> outboundSocketBindings = group.outboundSocketBindings();
    for (OutboundSocketBinding each : outboundSocketBindings) {
        configureSocketBinding(address, each, list);
    }
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding)

Example 8 with SocketBinding

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

the class UndertowSocketBindingsCustomizerTest method testExplicitHttpPort.

@Test
public void testExplicitHttpPort() {
    UndertowSocketBindingsCustomizer customizer = new UndertowSocketBindingsCustomizer();
    customizer.fraction = new UndertowFraction();
    customizer.fraction.httpPort(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("8675");
    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)

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