Search in sources :

Example 6 with SimpleAttributeDefinitionBuilder

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

the class ForkProtocolResourceRegistrationHandler method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
    String protocolName = context.getCurrentAddressValue();
    String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, operation).asString();
    Class<? extends Protocol> protocolClass = ProtocolResourceRegistrationHandler.findProtocolClass(context, protocolName, moduleName);
    final Map<String, Attribute> attributes = ProtocolMetricsHandler.findProtocolAttributes(protocolClass);
    OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {

        @Override
        public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
            Map<String, ModelNode> result = new HashMap<>();
            for (Attribute attribute : attributes.values()) {
                ModelNode value = new ModelNode();
                value.get(ModelDescriptionConstants.DESCRIPTION).set(attribute.getDescription());
                result.put(attribute.getName(), value);
            }
            return result;
        }

        @Override
        public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
            return Collections.emptyMap();
        }
    };
    ManagementResourceRegistration protocolRegistration = registration.registerOverrideModel(protocolName, provider);
    ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this);
    for (Attribute attribute : attributes.values()) {
        String name = attribute.getName();
        FieldType type = FieldType.valueOf(attribute.getType());
        protocolRegistration.registerMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType()).setStorageRuntime().build(), handler);
    }
}
Also used : Locale(java.util.Locale) Attribute(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute) HashMap(java.util.HashMap) OverrideDescriptionProvider(org.jboss.as.controller.descriptions.OverrideDescriptionProvider) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) FieldType(org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType) ModelNode(org.jboss.dmr.ModelNode) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder)

Example 7 with SimpleAttributeDefinitionBuilder

use of org.jboss.as.controller.SimpleAttributeDefinitionBuilder 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).setAllowNull(true).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 8 with SimpleAttributeDefinitionBuilder

use of org.jboss.as.controller.SimpleAttributeDefinitionBuilder 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) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 9 with SimpleAttributeDefinitionBuilder

use of org.jboss.as.controller.SimpleAttributeDefinitionBuilder 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 10 with SimpleAttributeDefinitionBuilder

use of org.jboss.as.controller.SimpleAttributeDefinitionBuilder 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)

Aggregations

SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)11 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)7 ModelNode (org.jboss.dmr.ModelNode)3 ModelType (org.jboss.dmr.ModelType)3 Attribute (org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.Attribute)2 FieldType (org.jboss.as.clustering.jgroups.subsystem.ProtocolMetricsHandler.FieldType)2 AbstractAttributeDefinitionBuilder (org.jboss.as.controller.AbstractAttributeDefinitionBuilder)2 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)2 OperationContext (org.jboss.as.controller.OperationContext)2 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)2 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)2 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)2 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)2 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)2 SimpleMapAttributeDefinition (org.jboss.as.controller.SimpleMapAttributeDefinition)2 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Locale (java.util.Locale)1 Map (java.util.Map)1