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);
}
}
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;
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations