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);
});
}
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);
}
}
}
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);
}
}
}
}
}
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);
});
});
}
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);
}
Aggregations