Search in sources :

Example 66 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.

the class EESubsystemXmlPersister method writeManagedScheduledExecutorServices.

private void writeManagedScheduledExecutorServices(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException {
    writer.writeStartElement(Element.MANAGED_SCHEDULED_EXECUTOR_SERVICES.getLocalName());
    for (Property property : subModel.asPropertyList()) {
        writer.writeStartElement(Element.MANAGED_SCHEDULED_EXECUTOR_SERVICE.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
        for (SimpleAttributeDefinition ad : ManagedScheduledExecutorServiceResourceDefinition.ATTRIBUTES) {
            ad.marshallAsAttribute(property.getValue(), writer);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) Property(org.jboss.dmr.Property)

Example 67 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.

the class DataSourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
            SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
        }
        for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
            PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
        }
    } else {
        ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_ATTRIBUTE);
        CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE);
        for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else if (attribute.getName().equals(ENLISTMENT_TRACE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, new EnlistmentTraceAttributeWriteHandler());
            } else if (attribute.getName().equals(CREDENTIAL_REFERENCE.getName()) || attribute.getName().equals(RECOVERY_CREDENTIAL_REFERENCE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, credentialReferenceWriteAttributeHandler);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteAttributeHandler);
            }
        }
        ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_PROPERTIES_ATTRIBUTES);
        for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredPropertiesWriteHandler);
            }
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) CredentialReferenceWriteAttributeHandler(org.jboss.as.controller.security.CredentialReferenceWriteAttributeHandler) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 68 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.

the class ConnectionPropertyDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(Constants.CONNECTION_PROPERTY_VALUE).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
        resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
    } else {
        resourceRegistration.registerReadOnlyAttribute(Constants.CONNECTION_PROPERTY_VALUE, null);
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder)

Example 69 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.

the class AbstractFederationSubsystemReader method parseConfig.

/**
 * Reads a element from the stream considering the parameters.
 *
 * @param reader XMLExtendedStreamReader instance from which the elements are read.
 * @param xmlElement Name of the Model Element to be parsed.
 * @param key Name of the attribute to be used to as the key for the model.
 * @param addOperations List of operations.
 * @param lastNode Parent ModelNode instance.
 * @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
 *
 * @return A ModelNode instance populated.
 *
 * @throws javax.xml.stream.XMLStreamException
 */
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
    if (!reader.getLocalName().equals(xmlElement.getName())) {
        return null;
    }
    ModelNode modelNode = Util.getEmptyOperation(ADD, null);
    int attributeCount = reader.getAttributeCount();
    for (int i = 0; i < attributeCount; i++) {
        String attributeLocalName = reader.getAttributeLocalName(i);
        if (ModelElement.forName(attributeLocalName) == null) {
            throw unexpectedAttribute(reader, i);
        }
    }
    for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
        String attributeValue = reader.getAttributeValue("", simpleAttributeDefinition.getXmlName());
        simpleAttributeDefinition.parseAndSetParameter(attributeValue, modelNode, reader);
    }
    String name = xmlElement.getName();
    if (key != null) {
        name = key;
        if (modelNode.hasDefined(key)) {
            name = modelNode.get(key).asString();
        } else {
            String attributeValue = reader.getAttributeValue("", key);
            if (attributeValue != null) {
                name = attributeValue;
            }
        }
    }
    modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
    addOperations.add(modelNode);
    return modelNode;
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 70 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseConfig.

/**
 * Reads a element from the stream considering the parameters.
 *
 * @param reader XMLExtendedStreamReader instance from which the elements are read.
 * @param xmlElement Name of the Model Element to be parsed.
 * @param key Name of the attribute to be used to as the key for the model.
 * @param addOperations List of operations.
 * @param lastNode Parent ModelNode instance.
 * @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
 *
 * @return A ModelNode instance populated.
 *
 * @throws javax.xml.stream.XMLStreamException
 */
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
    if (!reader.getLocalName().equals(xmlElement.getName())) {
        return null;
    }
    ModelNode modelNode = Util.getEmptyOperation(ADD, null);
    int attributeCount = reader.getAttributeCount();
    for (int i = 0; i < attributeCount; i++) {
        String attributeLocalName = reader.getAttributeLocalName(i);
        if (ModelElement.forName(attributeLocalName) == null) {
            throw unexpectedAttribute(reader, i);
        }
    }
    for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
        simpleAttributeDefinition.parseAndSetParameter(reader.getAttributeValue("", simpleAttributeDefinition.getXmlName()), modelNode, reader);
    }
    String name = xmlElement.getName();
    if (key != null) {
        name = key;
        if (modelNode.hasDefined(key)) {
            name = modelNode.get(key).asString();
        } else {
            String attributeValue = reader.getAttributeValue("", key);
            if (attributeValue != null) {
                name = attributeValue;
            }
        }
    }
    modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
    addOperations.add(modelNode);
    return modelNode;
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)89 ModelNode (org.jboss.dmr.ModelNode)47 PathAddress (org.jboss.as.controller.PathAddress)14 Property (org.jboss.dmr.Property)13 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)9 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)9 HashSet (java.util.HashSet)8 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)8 XMLStreamException (javax.xml.stream.XMLStreamException)7 OperationContext (org.jboss.as.controller.OperationContext)4 ArrayList (java.util.ArrayList)3 AbstractAttributeDefinitionBuilder (org.jboss.as.controller.AbstractAttributeDefinitionBuilder)3 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)3 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)3 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)3 SimpleMapAttributeDefinition (org.jboss.as.controller.SimpleMapAttributeDefinition)3 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)3 ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)2 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)2