Search in sources :

Example 1 with ProtocolType

use of org.apache.qpid.server.model.Protocol.ProtocolType in project qpid-broker-j by apache.

the class PortFactory method getProtocolType.

private ProtocolType getProtocolType(Map<String, Object> portAttributes, Broker<?> broker) {
    Model model = broker.getModel();
    ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry();
    Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = typeRegistry.getAttributeTypes(Port.class);
    ConfiguredSettableAttribute protocolsAttribute = (ConfiguredSettableAttribute) attributeTypes.get(Port.PROTOCOLS);
    Set<Protocol> protocols = (Set<Protocol>) protocolsAttribute.convert(portAttributes.get(Port.PROTOCOLS), broker);
    ProtocolType protocolType = null;
    if (protocols == null || protocols.isEmpty()) {
        // defaulting to AMQP if protocol is not specified
        protocolType = ProtocolType.AMQP;
    } else {
        for (Protocol protocol : protocols) {
            if (protocolType == null) {
                protocolType = protocol.getProtocolType();
            } else if (protocolType != protocol.getProtocolType()) {
                throw new IllegalConfigurationException("Found different protocol types '" + protocolType + "' and '" + protocol.getProtocolType() + "' for port configuration: " + portAttributes);
            }
        }
    }
    return protocolType;
}
Also used : ConfiguredObjectAttribute(org.apache.qpid.server.model.ConfiguredObjectAttribute) Set(java.util.Set) ConfiguredSettableAttribute(org.apache.qpid.server.model.ConfiguredSettableAttribute) ProtocolType(org.apache.qpid.server.model.Protocol.ProtocolType) Model(org.apache.qpid.server.model.Model) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectTypeRegistry(org.apache.qpid.server.model.ConfiguredObjectTypeRegistry) Protocol(org.apache.qpid.server.model.Protocol)

Aggregations

Set (java.util.Set)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 ConfiguredObjectAttribute (org.apache.qpid.server.model.ConfiguredObjectAttribute)1 ConfiguredObjectTypeRegistry (org.apache.qpid.server.model.ConfiguredObjectTypeRegistry)1 ConfiguredSettableAttribute (org.apache.qpid.server.model.ConfiguredSettableAttribute)1 Model (org.apache.qpid.server.model.Model)1 Protocol (org.apache.qpid.server.model.Protocol)1 ProtocolType (org.apache.qpid.server.model.Protocol.ProtocolType)1