Search in sources :

Example 1 with ProxyConfiguration

use of org.jboss.modcluster.config.ProxyConfiguration in project wildfly by wildfly.

the class ModClusterConfigurationServiceBuilder method getValue.

@Override
public ModClusterConfiguration getValue() throws IllegalStateException, IllegalArgumentException {
    // Advertise
    if (advertiseSocketDependency != null) {
        final SocketBinding binding = advertiseSocketDependency.getValue();
        builder.advertise().setAdvertiseSocketAddress(binding.getMulticastSocketAddress()).setAdvertiseInterface(binding.getSocketAddress().getAddress());
        if (!isMulticastEnabled(binding.getSocketBindings().getDefaultInterfaceBinding().getNetworkInterfaces())) {
            ROOT_LOGGER.multicastInterfaceNotAvailable();
        }
    }
    // Proxies
    List<ProxyConfiguration> proxies = new LinkedList<>();
    for (final ValueDependency<OutboundSocketBinding> outboundSocketBindingValueDependency : outboundSocketBindings) {
        OutboundSocketBinding binding = outboundSocketBindingValueDependency.getValue();
        proxies.add(new ProxyConfiguration() {

            @Override
            public InetSocketAddress getRemoteAddress() {
                // Don't do resolving here, let mod_cluster deal with it
                return new InetSocketAddress(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort());
            }

            @Override
            public InetSocketAddress getLocalAddress() {
                if (binding.getOptionalSourceAddress() != null) {
                    return new InetSocketAddress(binding.getOptionalSourceAddress(), binding.getAbsoluteSourcePort() == null ? 0 : binding.getAbsoluteSourcePort());
                } else if (binding.getAbsoluteSourcePort() != null) {
                    // Bind to port only if source address is not configured
                    return new InetSocketAddress(binding.getAbsoluteSourcePort());
                }
                // No binding configured so don't bind
                return null;
            }
        });
    }
    builder.mcmp().setProxyConfigurations(proxies);
    // SSL
    if (sslContextDependency != null) {
        builder.mcmp().setSocketFactory(sslContextDependency.getValue().getSocketFactory());
    }
    return builder.build();
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) ProxyConfiguration(org.jboss.modcluster.config.ProxyConfiguration) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) InetSocketAddress(java.net.InetSocketAddress) LinkedList(java.util.LinkedList)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 LinkedList (java.util.LinkedList)1 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)1 SocketBinding (org.jboss.as.network.SocketBinding)1 ProxyConfiguration (org.jboss.modcluster.config.ProxyConfiguration)1