Search in sources :

Example 6 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 7 with SocketBindingGroup

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

the class SocketBindingGroupExtension method afterBeanDiscovery.

@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
    List<SimpleKey> configuredGroups = this.configView.simpleSubkeys(ROOT);
    for (SimpleKey groupName : configuredGroups) {
        Set<Bean<?>> groups = beanManager.getBeans(SocketBindingGroup.class, AnyLiteral.INSTANCE);
        AtomicBoolean producerRequired = new AtomicBoolean(false);
        if (groups.stream().noneMatch(e -> e.getQualifiers().stream().anyMatch(anno -> anno instanceof Named && ((Named) anno).value().equals(groupName)))) {
            SocketBindingGroup group = new SocketBindingGroup(groupName.name(), null, "0");
            applyConfiguration(group);
            if (producerRequired.get()) {
                CommonBean<SocketBindingGroup> interfaceBean = CommonBeanBuilder.newBuilder(SocketBindingGroup.class).beanClass(SocketBindingGroupExtension.class).scope(ApplicationScoped.class).addQualifier(AnyLiteral.INSTANCE).addQualifier(new NamedLiteral(group.name())).createSupplier(() -> group).addType(SocketBindingGroup.class).addType(Object.class).build();
                abd.addBean(interfaceBean);
            }
        }
    }
}
Also used : AfterBeanDiscovery(javax.enterprise.inject.spi.AfterBeanDiscovery) Set(java.util.Set) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AnyLiteral(org.jboss.weld.literal.AnyLiteral) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) List(java.util.List) CommonBean(org.wildfly.swarm.spi.api.cdi.CommonBean) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) Observes(javax.enterprise.event.Observes) NamedLiteral(org.jboss.weld.literal.NamedLiteral) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Named(javax.inject.Named) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Bean(javax.enterprise.inject.spi.Bean) BeanManager(javax.enterprise.inject.spi.BeanManager) CommonBeanBuilder(org.wildfly.swarm.spi.api.cdi.CommonBeanBuilder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Named(javax.inject.Named) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) NamedLiteral(org.jboss.weld.literal.NamedLiteral) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) CommonBean(org.wildfly.swarm.spi.api.cdi.CommonBean) Bean(javax.enterprise.inject.spi.Bean)

Example 8 with SocketBindingGroup

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

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