Search in sources :

Example 1 with TransportProviderFactory

use of org.apache.qpid.server.plugin.TransportProviderFactory 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)

Example 2 with TransportProviderFactory

use of org.apache.qpid.server.plugin.TransportProviderFactory in project qpid-broker-j by apache.

the class AmqpPortImpl method getAllAvailableTransportCombinations.

@SuppressWarnings("unused")
public static Collection<String> getAllAvailableTransportCombinations() {
    Set<Set<Transport>> combinations = new HashSet<>();
    for (TransportProviderFactory providerFactory : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) {
        combinations.addAll(providerFactory.getSupportedTransports());
    }
    Set<String> combinationsAsString = new HashSet<>(combinations.size());
    ObjectMapper mapper = new ObjectMapper();
    for (Set<Transport> combination : combinations) {
        try (StringWriter writer = new StringWriter()) {
            mapper.writeValue(writer, combination);
            combinationsAsString.add(writer.toString());
        } catch (IOException e) {
            throw new IllegalArgumentException("Unexpected IO Exception generating JSON string", e);
        }
    }
    return Collections.unmodifiableSet(combinationsAsString);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) IOException(java.io.IOException) StringWriter(java.io.StringWriter) TransportProviderFactory(org.apache.qpid.server.plugin.TransportProviderFactory) AcceptingTransport(org.apache.qpid.server.transport.AcceptingTransport) Transport(org.apache.qpid.server.model.Transport) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 Transport (org.apache.qpid.server.model.Transport)2 QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)2 TransportProviderFactory (org.apache.qpid.server.plugin.TransportProviderFactory)2 AcceptingTransport (org.apache.qpid.server.transport.AcceptingTransport)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Set (java.util.Set)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 PortBindFailureException (org.apache.qpid.server.transport.PortBindFailureException)1 TransportProvider (org.apache.qpid.server.transport.TransportProvider)1