Search in sources :

Example 6 with ConfiguredObjectAttribute

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

the class ManagementModeStoreHandler method getPortProtocolsAttribute.

private Set<Protocol> getPortProtocolsAttribute(Map<String, Object> attributes) {
    Object object = attributes.get(Port.PROTOCOLS);
    if (object == null) {
        return null;
    }
    Model model = _parent.getModel();
    ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry();
    Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = typeRegistry.getAttributeTypes(Port.class);
    ConfiguredSettableAttribute protocolsAttribute = (ConfiguredSettableAttribute) attributeTypes.get(Port.PROTOCOLS);
    return (Set<Protocol>) protocolsAttribute.convert(object, _parent);
}
Also used : ConfiguredObjectAttribute(org.apache.qpid.server.model.ConfiguredObjectAttribute) Set(java.util.Set) ConfiguredSettableAttribute(org.apache.qpid.server.model.ConfiguredSettableAttribute) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectTypeRegistry(org.apache.qpid.server.model.ConfiguredObjectTypeRegistry)

Example 7 with ConfiguredObjectAttribute

use of org.apache.qpid.server.model.ConfiguredObjectAttribute 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

ConfiguredObjectAttribute (org.apache.qpid.server.model.ConfiguredObjectAttribute)7 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 ConfiguredObjectTypeRegistry (org.apache.qpid.server.model.ConfiguredObjectTypeRegistry)5 Model (org.apache.qpid.server.model.Model)5 ConfiguredSettableAttribute (org.apache.qpid.server.model.ConfiguredSettableAttribute)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Set (java.util.Set)2 LinkedHashMap (java.util.LinkedHashMap)1 TreeMap (java.util.TreeMap)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 ConfiguredObjectMethodAttribute (org.apache.qpid.server.model.ConfiguredObjectMethodAttribute)1 ManagedObject (org.apache.qpid.server.model.ManagedObject)1 Protocol (org.apache.qpid.server.model.Protocol)1 ProtocolType (org.apache.qpid.server.model.Protocol.ProtocolType)1