use of org.jboss.as.controller.AttributeDefinition 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;
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class StatisticsResourceDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
for (AttributeDefinition attribute : getAttributesFromPlugin(plugin)) {
resourceRegistration.registerMetric(attribute, new PoolMetrics.ParametrizedPoolMetricsHandler(plugin));
}
// adding enable/disable for pool stats
OperationStepHandler readHandler = new PoolStatisticsRuntimeAttributeReadHandler(plugin);
OperationStepHandler writeHandler = new PoolStatisticsRuntimeAttributeWriteHandler(plugin);
resourceRegistration.registerReadWriteAttribute(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_STATISTICS_ENABLED, readHandler, writeHandler);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class JdbcDriverAdd method populateModel.
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
final String driverName = PathAddress.pathAddress(address).getLastElement().getValue();
for (AttributeDefinition attribute : Constants.JDBC_DRIVER_ATTRIBUTES) {
// https://issues.jboss.org/browse/WFLY-9324 skip validation on driver-name
if (!attribute.getName().equals(DRIVER_NAME_NAME)) {
attribute.validateAndSet(operation, model);
}
}
// this shouldn't be here anymore
model.get(DRIVER_NAME.getName()).set(driverName);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class CachedConnectionManagerAdd method createResource.
@Override
protected Resource createResource(OperationContext context, ModelNode operation) {
// exists, so long as it is configured with the values the parser generates (i.e. no defined attributes)
try {
// will fail in normal case
Resource existing = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
ModelNode model = existing.getModel();
boolean allDefault = true;
for (JcaCachedConnectionManagerDefinition.CcmParameters param : JcaCachedConnectionManagerDefinition.CcmParameters.values()) {
if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) {
AttributeDefinition ad = param.getAttribute();
// else someone changed something and we need to account for that
assert !ad.isRequired() : ad.getName();
if (model.hasDefined(ad.getName())) {
allDefault = false;
break;
}
} else {
// Someone added a new param since WFLY-2640/WFLY-8141 and did not account for it above
throw new IllegalStateException();
}
}
if (allDefault) {
// We can use the existing resource as if we just created it
return existing;
}
// else fall through and call super method which will fail due to resource already being present
} catch (Resource.NoSuchResourceException normal) {
// normal case; resource doesn't exist yet so fall through
}
return super.createResource(context, operation);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class JcaCachedConnectionManagerDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
for (final CcmParameters parameter : CcmParameters.values()) {
if (parameter != CcmParameters.INSTALL) {
resourceRegistration.registerReadWriteAttribute(parameter.getAttribute(), null, JcaCachedConnectionManagerWriteHandler.INSTANCE);
} else {
AttributeDefinition ad = parameter.getAttribute();
resourceRegistration.registerReadWriteAttribute(ad, null, new ReloadRequiredWriteAttributeHandler(ad));
}
}
}
Aggregations