Search in sources :

Example 11 with SimpleAttributeDefinitionBuilder

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

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