use of org.apache.qpid.server.model.ConfiguredSettableAttribute in project qpid-broker-j by apache.
the class ApiDocsServlet method writeAttributesTable.
private void writeAttributesTable(final PrintWriter writer, final Collection<ConfiguredObjectAttribute<?, ?>> attributeTypes) {
writer.println("<table class=\"attributes\">");
writer.println("<thead>");
writer.println("<tr><th class=\"name\">Attribute Name</th><th class=\"type\">Type</th><th class=\"properties\">Properties</th><th class=\"description\">Description</th></tr>");
writer.println("</thead>");
writer.println("<tbody>");
for (ConfiguredObjectAttribute attribute : attributeTypes) {
String properties;
if (attribute instanceof ConfiguredSettableAttribute) {
ConfiguredSettableAttribute settableAttribute = (ConfiguredSettableAttribute) attribute;
if (settableAttribute.isImmutable()) {
properties = "read/settable on create only";
} else {
properties = "read/write";
}
} else {
properties = "read only";
}
writer.println("<tr><td class=\"name\">" + attribute.getName() + "</td><td class=\"type\">" + renderType(attribute) + "</td><td class=\"properties\">" + properties + "</td><td class=\"description\">" + attribute.getDescription() + "</td></tr>");
}
writer.println("</tbody>");
writer.println("</table>");
}
use of org.apache.qpid.server.model.ConfiguredSettableAttribute in project qpid-broker-j by apache.
the class MetaDataServlet method processAttributes.
private Map<String, Map> processAttributes(final Class<? extends ConfiguredObject> type, final Model model) {
Collection<ConfiguredObjectAttribute<?, ?>> attributes = model.getTypeRegistry().getAttributeTypes(type).values();
Map<String, Map> attributeDetails = new LinkedHashMap<>();
for (ConfiguredObjectAttribute<?, ?> attribute : attributes) {
Map<String, Object> attrDetails = new LinkedHashMap<>();
attrDetails.put("type", attribute.getType().getSimpleName());
if (!"".equals(attribute.getDescription())) {
attrDetails.put("description", attribute.getDescription());
}
if (attribute.isDerived()) {
attrDetails.put("derived", attribute.isDerived());
}
if (!attribute.isDerived()) {
ConfiguredSettableAttribute automatedAttribute = (ConfiguredSettableAttribute) attribute;
if (!"".equals(automatedAttribute.defaultValue())) {
attrDetails.put("defaultValue", automatedAttribute.defaultValue());
}
if (automatedAttribute.isMandatory()) {
attrDetails.put("mandatory", automatedAttribute.isMandatory());
}
if (automatedAttribute.isImmutable()) {
attrDetails.put("immutable", automatedAttribute.isImmutable());
}
if (!(automatedAttribute.validValues()).isEmpty()) {
Collection<String> validValues = ((ConfiguredSettableAttribute<?, ?>) attribute).validValues();
Collection<Object> convertedValues = new ArrayList<>(validValues.size());
for (String value : validValues) {
convertedValues.add(((ConfiguredSettableAttribute<?, ?>) attribute).convert(value, null));
}
attrDetails.put("validValues", convertedValues);
} else if (!"".equals(automatedAttribute.validValuePattern())) {
attrDetails.put("validValuesPattern", automatedAttribute.validValuePattern());
}
}
if (attribute.isSecure()) {
attrDetails.put("secure", attribute.isSecure());
}
if (attribute.isOversized()) {
attrDetails.put("oversize", attribute.isOversized());
}
attributeDetails.put(attribute.getName(), attrDetails);
}
return attributeDetails;
}
use of org.apache.qpid.server.model.ConfiguredSettableAttribute 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);
}
use of org.apache.qpid.server.model.ConfiguredSettableAttribute 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;
}
Aggregations