Search in sources :

Example 61 with SimpleAttributeDefinition

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

the class StatisticsResourceDefinition method getAttributesFromPlugin.

public static List<AttributeDefinition> getAttributesFromPlugin(StatisticsPlugin plugin) {
    LinkedList<AttributeDefinition> result = new LinkedList<>();
    for (String name : plugin.getNames()) {
        ModelType modelType = ModelType.STRING;
        if (plugin.getType(name) == int.class) {
            modelType = ModelType.INT;
        }
        if (plugin.getType(name) == long.class) {
            modelType = ModelType.LONG;
        }
        SimpleAttributeDefinition attribute = new SimpleAttributeDefinitionBuilder(name, modelType).setRequired(false).setStorageRuntime().build();
        result.add(attribute);
    }
    return result;
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelType(org.jboss.dmr.ModelType) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) LinkedList(java.util.LinkedList)

Example 62 with SimpleAttributeDefinition

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

the class XaDataSourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        for (final SimpleAttributeDefinition attribute : XA_DATASOURCE_ATTRIBUTE) {
            SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
        for (final PropertiesAttributeDefinition attribute : XA_DATASOURCE_PROPERTIES_ATTRIBUTES) {
            PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
    } else {
        ReloadRequiredWriteAttributeHandler reloadRequiredWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_ATTRIBUTE);
        for (final SimpleAttributeDefinition attribute : XA_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 {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteHandler);
            }
        }
        ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_PROPERTIES_ATTRIBUTES);
        for (final PropertiesAttributeDefinition attribute : XA_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) 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 63 with SimpleAttributeDefinition

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

the class XaDataSourcePropertyDefinition method registerAttributes.

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

Example 64 with SimpleAttributeDefinition

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

the class EESubsystemXmlPersister method writeDefaultBindingsElement.

private void writeDefaultBindingsElement(XMLExtendedStreamWriter writer, ModelNode eeSubSystem) throws XMLStreamException {
    if (eeSubSystem.hasDefined(EESubsystemModel.SERVICE) && eeSubSystem.get(EESubsystemModel.SERVICE).hasDefined(EESubsystemModel.DEFAULT_BINDINGS)) {
        ModelNode defaultBindingsNode = eeSubSystem.get(EESubsystemModel.SERVICE, EESubsystemModel.DEFAULT_BINDINGS);
        writer.writeStartElement(Element.DEFAULT_BINDINGS.getLocalName());
        for (SimpleAttributeDefinition ad : DefaultBindingsResourceDefinition.ATTRIBUTES) {
            ad.marshallAsAttribute(defaultBindingsNode, writer);
        }
        writer.writeEndElement();
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 65 with SimpleAttributeDefinition

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

the class EESubsystemXmlPersister method writeDirectoryElement.

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

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