Search in sources :

Example 66 with Property

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;
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) Properties(java.util.Properties) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 67 with Property

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);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 68 with Property

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);
    }
}
Also used : Property(org.jboss.dmr.Property)

Example 69 with Property

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;
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Properties(java.util.Properties) Property(org.jboss.dmr.Property)

Example 70 with Property

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);
        }
    }
}
Also used : HashMap(java.util.HashMap) ModelNode(org.jboss.dmr.ModelNode) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.jboss.dmr.Property)

Aggregations

Property (org.jboss.dmr.Property)179 ModelNode (org.jboss.dmr.ModelNode)144 HashMap (java.util.HashMap)19 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 PathAddress (org.jboss.as.controller.PathAddress)11 ArrayList (java.util.ArrayList)10 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)6 Properties (java.util.Properties)5 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3 HttpGet (org.apache.http.client.methods.HttpGet)3