Search in sources :

Example 1 with ConnectionPropertyEnricher

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

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

the class AMQPConnection_0_8Impl method protocolInitiationReceived.

private synchronized void protocolInitiationReceived(ProtocolInitiation pi) {
    // this ensures the codec never checks for a PI message again
    _decoder.setExpectProtocolInitiation(false);
    try {
        // Fails if not correct
        ProtocolVersion pv = pi.checkVersion();
        setProtocolVersion(pv);
        StringBuilder mechanismBuilder = new StringBuilder();
        for (String mechanismName : getPort().getAuthenticationProvider().getAvailableMechanisms(getTransport().isSecure())) {
            if (mechanismBuilder.length() != 0) {
                mechanismBuilder.append(' ');
            }
            mechanismBuilder.append(mechanismName);
        }
        String mechanisms = mechanismBuilder.toString();
        String locales = "en_US";
        Map<String, Object> props = Collections.emptyMap();
        for (ConnectionPropertyEnricher enricher : getPort().getConnectionPropertyEnrichers()) {
            props = enricher.addConnectionProperties(this, props);
        }
        FieldTable serverProperties = FieldTable.convertToFieldTable(props);
        AMQMethodBody responseBody = getMethodRegistry().createConnectionStartBody((short) getProtocolMajorVersion(), (short) pv.getActualMinorVersion(), serverProperties, mechanisms.getBytes(US_ASCII), locales.getBytes(US_ASCII));
        writeFrame(responseBody.generateFrame(0));
        _state = ConnectionState.AWAIT_START_OK;
        _sender.flush();
    } catch (QpidException e) {
        LOGGER.debug("Received unsupported protocol initiation for protocol version: {} ", getProtocolVersion());
        writeFrame(new ProtocolInitiation(ProtocolVersion.getLatestSupportedVersion()));
        _sender.flush();
    }
}
Also used : QpidException(org.apache.qpid.server.QpidException) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) ProtocolVersion(org.apache.qpid.server.protocol.ProtocolVersion)

Example 3 with ConnectionPropertyEnricher

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

the class AMQPConnection_1_0Impl method sendOpen.

private void sendOpen(final int channelMax, final int maxFrameSize) {
    Open open = new Open();
    Map<String, Object> props = Collections.emptyMap();
    for (ConnectionPropertyEnricher enricher : getPort().getConnectionPropertyEnrichers()) {
        props = enricher.addConnectionProperties(this, props);
    }
    for (Map.Entry<String, Object> entry : props.entrySet()) {
        _properties.put(Symbol.valueOf(entry.getKey()), entry.getValue());
    }
    if (_receivingSessions == null) {
        _receivingSessions = new Session_1_0[channelMax + 1];
        _sendingSessions = new Session_1_0[channelMax + 1];
    }
    if (channelMax < _channelMax) {
        _channelMax = channelMax;
    }
    open.setChannelMax(UnsignedShort.valueOf((short) channelMax));
    open.setContainerId(getAddressSpace() == null ? UUID.randomUUID().toString() : getAddressSpace().getId().toString());
    open.setMaxFrameSize(UnsignedInteger.valueOf(maxFrameSize));
    // TODO - should we try to set the hostname based on the connection information?
    // open.setHostname();
    open.setIdleTimeOut(UnsignedInteger.valueOf(_incomingIdleTimeout));
    // set the offered capabilities
    if (_offeredCapabilities != null && !_offeredCapabilities.isEmpty()) {
        open.setOfferedCapabilities(_offeredCapabilities.toArray(new Symbol[_offeredCapabilities.size()]));
    }
    if (_remoteDesiredCapabilities != null && _remoteDesiredCapabilities.contains(SoleConnectionConnectionProperties.SOLE_CONNECTION_FOR_CONTAINER)) {
        _properties.put(SoleConnectionConnectionProperties.SOLE_CONNECTION_DETECTION_POLICY, SoleConnectionDetectionPolicy.STRONG);
    }
    open.setProperties(_properties);
    sendFrame(CONNECTION_CONTROL_CHANNEL, open);
}
Also used : Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open)

Example 4 with ConnectionPropertyEnricher

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

the class ServerConnectionDelegate method init.

@Override
public void init(final ServerConnection serverConnection, final ProtocolHeader hdr) {
    assertState(serverConnection, ConnectionState.INIT);
    serverConnection.send(new ProtocolHeader(1, 0, 10));
    Map<String, Object> props = Collections.emptyMap();
    for (ConnectionPropertyEnricher enricher : _port.getConnectionPropertyEnrichers()) {
        props = enricher.addConnectionProperties(serverConnection.getAmqpConnection(), props);
    }
    serverConnection.sendConnectionStart(props, _mechanisms, Collections.singletonList((Object) "en_US"));
    _state = ConnectionState.AWAIT_START_OK;
}
Also used : ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher)

Aggregations

ConnectionPropertyEnricher (org.apache.qpid.server.plugin.ConnectionPropertyEnricher)4 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 QpidException (org.apache.qpid.server.QpidException)1 QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)1 ProtocolVersion (org.apache.qpid.server.protocol.ProtocolVersion)1 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)1 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)1