Search in sources :

Example 1 with TransportProvider

use of org.apache.qpid.server.transport.TransportProvider in project qpid-broker-j by apache.

the class AmqpPortImpl method onActivate.

@Override
protected State onActivate() {
    if (getAncestor(SystemConfig.class).isManagementMode()) {
        return State.QUIESCED;
    } else {
        Collection<Transport> transports = getTransports();
        TransportProvider transportProvider = null;
        final HashSet<Transport> transportSet = new HashSet<>(transports);
        for (TransportProviderFactory tpf : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) {
            if (tpf.getSupportedTransports().contains(transports)) {
                transportProvider = tpf.getTransportProvider(transportSet);
            }
        }
        if (transportProvider == null) {
            throw new IllegalConfigurationException("No transport providers found which can satisfy the requirement to support the transports: " + transports);
        }
        if (transports.contains(Transport.SSL) || transports.contains(Transport.WSS)) {
            _sslContext = createSslContext();
        }
        Protocol defaultSupportedProtocolReply = getDefaultAmqpSupportedReply();
        try {
            _transport = transportProvider.createTransport(transportSet, _sslContext, this, getProtocols(), defaultSupportedProtocolReply);
            _transport.start();
            _boundPort = _transport.getAcceptingPort();
            for (Transport transport : getTransports()) {
                _container.getEventLogger().message(BrokerMessages.LISTENING(String.valueOf(transport), _transport.getAcceptingPort()));
            }
            return State.ACTIVE;
        } catch (PortBindFailureException e) {
            _container.getEventLogger().message(PortMessages.BIND_FAILED(getType().toUpperCase(), getPort()));
            throw e;
        }
    }
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) PortBindFailureException(org.apache.qpid.server.transport.PortBindFailureException) TransportProviderFactory(org.apache.qpid.server.plugin.TransportProviderFactory) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) AcceptingTransport(org.apache.qpid.server.transport.AcceptingTransport) Transport(org.apache.qpid.server.model.Transport) Protocol(org.apache.qpid.server.model.Protocol) TransportProvider(org.apache.qpid.server.transport.TransportProvider) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 Protocol (org.apache.qpid.server.model.Protocol)1 SystemConfig (org.apache.qpid.server.model.SystemConfig)1 Transport (org.apache.qpid.server.model.Transport)1 QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)1 TransportProviderFactory (org.apache.qpid.server.plugin.TransportProviderFactory)1 AcceptingTransport (org.apache.qpid.server.transport.AcceptingTransport)1 PortBindFailureException (org.apache.qpid.server.transport.PortBindFailureException)1 TransportProvider (org.apache.qpid.server.transport.TransportProvider)1