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);
}
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();
}
}
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);
}
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;
}
Aggregations