Search in sources :

Example 11 with QpidServiceLoader

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

the class BrokerImpl method registerSystemAddressSpaces.

private void registerSystemAddressSpaces() {
    QpidServiceLoader qpidServiceLoader = new QpidServiceLoader();
    Iterable<SystemAddressSpaceCreator> factories = qpidServiceLoader.instancesOf(SystemAddressSpaceCreator.class);
    for (SystemAddressSpaceCreator creator : factories) {
        creator.register(_addressSpaceRegistry);
    }
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) SystemAddressSpaceCreator(org.apache.qpid.server.plugin.SystemAddressSpaceCreator)

Example 12 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader 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 13 with QpidServiceLoader

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

the class AmqpPortImpl method onOpen.

@Override
protected void onOpen() {
    super.onOpen();
    _protocolHandshakeTimeout = getContextValue(Long.class, AmqpPort.PROTOCOL_HANDSHAKE_TIMEOUT);
    _connectionWarnCount = getContextValue(Integer.class, OPEN_CONNECTIONS_WARN_PERCENT);
    _closeWhenNoRoute = getContextValue(Boolean.class, AmqpPort.CLOSE_WHEN_NO_ROUTE);
    _sessionCountLimit = getContextValue(Integer.class, AmqpPort.SESSION_COUNT_LIMIT);
    _heartBeatDelay = getContextValue(Integer.class, AmqpPort.HEART_BEAT_DELAY);
    _tlsSessionTimeout = getContextValue(Integer.class, AmqpPort.TLS_SESSION_TIMEOUT);
    _tlsSessionCacheSize = getContextValue(Integer.class, AmqpPort.TLS_SESSION_CACHE_SIZE);
    @SuppressWarnings("unchecked") List<String> configurationPropertyEnrichers = getContextValue(List.class, AmqpPort.CONNECTION_PROPERTY_ENRICHERS);
    List<ConnectionPropertyEnricher> enrichers = new ArrayList<>(configurationPropertyEnrichers.size());
    final Map<String, ConnectionPropertyEnricher> enrichersByType = new QpidServiceLoader().getInstancesByType(ConnectionPropertyEnricher.class);
    for (String enricherName : configurationPropertyEnrichers) {
        ConnectionPropertyEnricher enricher = enrichersByType.get(enricherName);
        if (enricher != null) {
            enrichers.add(enricher);
        } else {
            LOGGER.warn("Ignoring unknown Connection Property Enricher type: '" + enricherName + "' on port " + this.getName());
        }
    }
    _connectionPropertyEnrichers = Collections.unmodifiableList(enrichers);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) ArrayList(java.util.ArrayList) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 14 with QpidServiceLoader

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

the class PreferenceFactory method convertMapToPreferenceValue.

private static PreferenceValue convertMapToPreferenceValue(String type, Map<String, Object> preferenceValueAttributes) {
    String implementationType = type;
    if (type != null && type.startsWith("X-")) {
        implementationType = "X-generic";
    }
    final Map<String, PreferenceValueFactoryService> preferenceValueFactories = new QpidServiceLoader().getInstancesByType(PreferenceValueFactoryService.class);
    final PreferenceValueFactoryService preferenceValueFactory = preferenceValueFactories.get(implementationType);
    if (preferenceValueFactory == null) {
        throw new IllegalArgumentException(String.format("Cannot find preference type factory for type '%s'", implementationType));
    }
    return preferenceValueFactory.createInstance(preferenceValueAttributes);
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader)

Example 15 with QpidServiceLoader

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

the class BrokerAdminFactory method createInstance.

BrokerAdmin createInstance(String type) {
    Map<String, BrokerAdmin> adminFacades = new QpidServiceLoader().getInstancesByType(BrokerAdmin.class);
    BrokerAdmin brokerAdmin = adminFacades.get(type);
    if (brokerAdmin == null) {
        throw new RuntimeException(String.format("Could not find BrokerAdmin implementation of type '%s'", type));
    }
    return brokerAdmin;
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader)

Aggregations

QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)22 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)3 ManagedObject (org.apache.qpid.server.model.ManagedObject)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ContainerType (org.apache.qpid.server.model.ContainerType)2 DynamicModel (org.apache.qpid.server.model.DynamicModel)2 Protocol (org.apache.qpid.server.model.Protocol)2 Transport (org.apache.qpid.server.model.Transport)2 ConfiguredObjectRegistration (org.apache.qpid.server.plugin.ConfiguredObjectRegistration)2 File (java.io.File)1 FileReader (java.io.FileReader)1 StringWriter (java.io.StringWriter)1 Principal (java.security.Principal)1