use of org.jboss.dmr.Property in project wildfly by wildfly.
the class IIOPSubsystemAdd method getConfigurationProperties.
/**
* <p>
* Obtains the subsystem configuration properties from the specified {@code ModelNode}, using default values for undefined
* properties. If the property has a IIOP equivalent, it is translated into its IIOP counterpart before being added to
* the returned {@code Properties} object.
* </p>
*
* @param model the {@code ModelNode} that contains the subsystem configuration properties.
* @return a {@code Properties} instance containing all configured subsystem properties.
* @throws OperationFailedException if an error occurs while resolving the properties.
*/
protected Properties getConfigurationProperties(OperationContext context, ModelNode model) throws OperationFailedException {
Properties properties = new Properties();
for (AttributeDefinition attrDefinition : IIOPRootDefinition.INSTANCE.getAttributes()) {
if (attrDefinition instanceof PropertiesAttributeDefinition) {
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
if (resolvedModelAttribute.isDefined()) {
for (final Property prop : resolvedModelAttribute.asPropertyList()) {
properties.setProperty(prop.getName(), prop.getValue().asString());
}
}
continue;
}
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
// FIXME
if (resolvedModelAttribute.isDefined()) {
String name = attrDefinition.getName();
String value = resolvedModelAttribute.asString();
String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
if (openjdkProperty != null) {
name = openjdkProperty;
}
properties.setProperty(name, value);
}
}
return properties;
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class OidcConfigService method setJSONValues.
private void setJSONValues(ModelNode json, ModelNode values) {
synchronized (values) {
for (Property prop : new ArrayList<>(values.asPropertyList())) {
String name = prop.getName();
ModelNode value = prop.getValue();
if (value.isDefined()) {
json.get(name).set(value);
}
}
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class MessagingXMLWriter method writeAcceptors.
private static void writeAcceptors(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (node.hasDefined(ACCEPTOR) || node.hasDefined(REMOTE_ACCEPTOR) || node.hasDefined(IN_VM_ACCEPTOR)) {
writer.writeStartElement(Element.ACCEPTORS.getLocalName());
if (node.hasDefined(HTTP_ACCEPTOR)) {
for (final Property property : node.get(HTTP_ACCEPTOR).asPropertyList()) {
writer.writeStartElement(Element.HTTP_ACCEPTOR.getLocalName());
HTTPAcceptorDefinition.HTTP_LISTENER.marshallAsAttribute(property.getValue(), writer);
writeAcceptorContent(writer, property);
writer.writeEndElement();
}
}
if (node.hasDefined(REMOTE_ACCEPTOR)) {
for (final Property property : node.get(REMOTE_ACCEPTOR).asPropertyList()) {
writer.writeStartElement(Element.NETTY_ACCEPTOR.getLocalName());
writeAcceptorContent(writer, property);
writer.writeEndElement();
}
}
if (node.hasDefined(IN_VM_ACCEPTOR)) {
for (final Property property : node.get(IN_VM_ACCEPTOR).asPropertyList()) {
writer.writeStartElement(Element.IN_VM_ACCEPTOR.getLocalName());
writeAcceptorContent(writer, property);
writer.writeEndElement();
}
}
if (node.hasDefined(ACCEPTOR)) {
for (final Property property : node.get(ACCEPTOR).asPropertyList()) {
writer.writeStartElement(Element.ACCEPTOR.getLocalName());
writeAcceptorContent(writer, property);
writer.writeEndElement();
}
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class JMSBridgeAdd method resolveContextProperties.
private Properties resolveContextProperties(AttributeDefinition attribute, OperationContext context, ModelNode model) throws OperationFailedException {
final ModelNode contextModel = attribute.resolveModelAttribute(context, model);
final Properties contextProperties = new Properties();
if (contextModel.isDefined()) {
for (Property property : contextModel.asPropertyList()) {
contextProperties.put(property.getName(), property.getValue().asString());
}
}
return contextProperties;
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class AbstractExpressionSupportTestCase method setExpressions.
private void setExpressions(PathAddress address, Map<PathAddress, Map<String, ModelNode>> expectedValues) throws IOException, MgmtOperationException {
ModelNode description = readResourceDescription(address);
ModelNode resource = readResource(address, true, false);
ModelNode resourceNoDefaults = readResource(address, false, false);
Map<String, ModelNode> expressionAttrs = new HashMap<String, ModelNode>();
Map<String, ModelNode> otherAttrs = new HashMap<String, ModelNode>();
Map<String, ModelNode> expectedAttrs = new HashMap<String, ModelNode>();
organizeAttributes(address, description, resource, resourceNoDefaults, expressionAttrs, otherAttrs, expectedAttrs);
for (Map.Entry<String, ModelNode> entry : expressionAttrs.entrySet()) {
writeAttribute(address, entry.getKey(), entry.getValue());
}
// Set the other attrs as well just to exercise the write-attribute handlers
for (Map.Entry<String, ModelNode> entry : otherAttrs.entrySet()) {
writeAttribute(address, entry.getKey(), entry.getValue());
}
if (expectedAttrs.size() > 0 && immediateValidation) {
// Validate that our write-attribute calls resulted in the expected values in the model
ModelNode modifiedResource = readResource(address, true, true);
for (Map.Entry<String, ModelNode> entry : expectedAttrs.entrySet()) {
ModelNode expectedValue = entry.getValue();
ModelNode modVal = modifiedResource.get(entry.getKey());
validateAttributeValue(address, entry.getKey(), expectedValue, modVal);
}
}
// Store the modified values for confirmation after HC reload
expectedValues.put(address, expectedAttrs);
// Recurse into children, being careful about what processes we are touching
for (Property descProp : description.get(CHILDREN).asPropertyList()) {
String childType = descProp.getName();
List<String> children = readChildrenNames(address, childType);
for (String child : children) {
setExpressions(address.append(PathElement.pathElement(childType, child)), expectedValues);
}
}
}
Aggregations