Search in sources :

Example 1 with OutboundSocketBinding

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

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

Example 3 with OutboundSocketBinding

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

the class SocketBindingCustomizer method customize.

@Override
public void customize() {
    if (!mailInstance.isUnsatisfied()) {
        MailFraction mailFraction = mailInstance.get();
        for (MailSession session : mailFraction.subresources().mailSessions()) {
            SMTPServer server = session.subresources().smtpServer();
            if (server != null && server instanceof EnhancedSMTPServer) {
                if (server.outboundSocketBindingRef() == null) {
                    String ref = "mail-smtp-" + ((EnhancedSMTPServer) server).sessionKey();
                    this.group.outboundSocketBinding(new OutboundSocketBinding(ref).remoteHost(((EnhancedSMTPServer) server).host()).remotePort(((EnhancedSMTPServer) server).port()));
                    ((EnhancedSMTPServer) server).outboundSocketBindingRef(ref);
                }
            }
        }
    }
}
Also used : OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) MailFraction(org.wildfly.swarm.mail.MailFraction) EnhancedSMTPServer(org.wildfly.swarm.mail.EnhancedSMTPServer) MailSession(org.wildfly.swarm.config.mail.MailSession) SMTPServer(org.wildfly.swarm.config.mail.mail_session.SMTPServer) EnhancedSMTPServer(org.wildfly.swarm.mail.EnhancedSMTPServer)

Example 4 with OutboundSocketBinding

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

the class RemoteConnectionSocketBindingCustomizer method customize.

@Override
public void customize() {
    List<Server> servers = fraction.subresources().servers();
    servers.stream().filter(e -> e instanceof EnhancedServer).forEach(server -> {
        ((EnhancedServer) server).remoteConnections().forEach(connection -> {
            OutboundSocketBinding binding = new OutboundSocketBinding(connection.name());
            binding.remoteHost(connection.host()).remotePort(connection.port());
            group.outboundSocketBinding(binding);
        });
    });
}
Also used : Inject(javax.inject.Inject) List(java.util.List) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Server(org.wildfly.swarm.config.messaging.activemq.Server) Customizer(org.wildfly.swarm.spi.api.Customizer) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Post(org.wildfly.swarm.spi.runtime.annotations.Post) Any(javax.enterprise.inject.Any) Named(javax.inject.Named) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) MessagingFraction(org.wildfly.swarm.messaging.MessagingFraction) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) Server(org.wildfly.swarm.config.messaging.activemq.Server) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding)

Example 5 with OutboundSocketBinding

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

the class RemoteConnectionSocketBindingCustomizerTest method testSocketBinding.

@Test
public void testSocketBinding() {
    this.fraction.defaultServer((server) -> {
        server.remoteConnection("postoffice");
    });
    this.customizer.customize();
    assertThat(this.group.outboundSocketBindings()).hasSize(1);
    OutboundSocketBinding binding = this.group.outboundSocketBindings().get(0);
    assertThat(binding.name()).isEqualTo("postoffice");
    assertThat(binding.remotePortExpression()).isEqualTo("" + MessagingProperties.DEFAULT_REMOTE_PORT);
    assertThat(binding.remoteHostExpression()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_HOST);
}
Also used : OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Test(org.junit.Test)

Aggregations

OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)6 SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)3 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)3 List (java.util.List)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Any (javax.enterprise.inject.Any)2 Inject (javax.inject.Inject)2 LinkedList (java.util.LinkedList)1 Consumer (java.util.function.Consumer)1 Instance (javax.enterprise.inject.Instance)1 Named (javax.inject.Named)1 PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 ValueExpression (org.jboss.dmr.ValueExpression)1 Test (org.junit.Test)1 MailSession (org.wildfly.swarm.config.mail.MailSession)1 SMTPServer (org.wildfly.swarm.config.mail.mail_session.SMTPServer)1 Server (org.wildfly.swarm.config.messaging.activemq.Server)1 Interface (org.wildfly.swarm.container.Interface)1 EnhancedSMTPServer (org.wildfly.swarm.mail.EnhancedSMTPServer)1