Skip to content

Commit

Permalink
WFLY-7732 Clustering subsystems use deprecated SimpleAttributeDefinit…
Browse files Browse the repository at this point in the history
…ion.setAllowNull(boolean)
  • Loading branch information
pferraro committed Dec 5, 2016
1 parent 267c85e commit d3795ee
Show file tree
Hide file tree
Showing 36 changed files with 56 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ParameterValidatorBuilder allowExpression(boolean allowsExpressions) {
@Override
public ParameterValidatorBuilder configure(AttributeDefinition definition) {
this.allowsExpressions = definition.isAllowExpression();
this.allowsUndefined = definition.isAllowNull();
this.allowsUndefined = !definition.isRequired();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {

Attribute(String name) {
this.definition = new StringListAttributeDefinition.Builder(name)
.setAllowNull(true)
.setRequired(false)
.setAttributeParser(AttributeParsers.COLLECTION)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down Expand Up @@ -204,7 +204,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public class ClusteredCacheResourceDefinition extends CacheResourceDefinition {

enum Attribute implements org.jboss.as.clustering.controller.Attribute {
MODE("mode", ModelType.STRING, null, new EnumValidatorBuilder<>(Mode.class)),
MODE("mode", ModelType.STRING, new EnumValidatorBuilder<>(Mode.class)),
REMOTE_TIMEOUT("remote-timeout", ModelType.LONG, new ModelNode(10000L)),
;
private final AttributeDefinition definition;
Expand All @@ -55,8 +55,8 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
this.definition = createBuilder(name, type, defaultValue).build();
}

Attribute(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validator) {
SimpleAttributeDefinitionBuilder builder = createBuilder(name, type, defaultValue);
Attribute(String name, ModelType type, ParameterValidatorBuilder validator) {
SimpleAttributeDefinitionBuilder builder = createBuilder(name, type, null);
this.definition = builder.setValidator(validator.configure(builder).build()).build();
}

Expand Down Expand Up @@ -87,7 +87,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(defaultValue != null)
.setRequired(defaultValue == null)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(false)
.setRequired(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, ModelType.LONG)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit(MeasurementUnit.MILLISECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
private final AttributeDefinition definition;

Attribute(String name, ModelType type, CapabilityReferenceRecorder reference) {
this.definition = createBuilder(name, type, true).setAllowExpression(false).setCapabilityReference(reference).build();
this.definition = createBuilder(name, type, false).setAllowExpression(false).setCapabilityReference(reference).build();
}

Attribute(String name, ModelType type, ParameterValidatorBuilder validator) {
SimpleAttributeDefinitionBuilder builder = createBuilder(name, type, true).setAllowExpression(true);
SimpleAttributeDefinitionBuilder builder = createBuilder(name, type, false).setAllowExpression(true);
this.definition = builder.setValidator(validator.configure(builder).build()).build();
}

Expand All @@ -113,7 +113,7 @@ enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute
private final AttributeDefinition definition;

DeprecatedAttribute(String name, ModelType type, InfinispanModel deprecation) {
this.definition = createBuilder(name, type, true).setAllowExpression(true).setDeprecated(deprecation.getVersion()).build();
this.definition = createBuilder(name, type, false).setAllowExpression(true).setDeprecated(deprecation.getVersion()).build();
}

@Override
Expand All @@ -122,9 +122,9 @@ public AttributeDefinition getDefinition() {
}
}

static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, boolean allowNull) {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, boolean required) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowNull(allowNull)
.setRequired(required)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
;
}
Expand Down Expand Up @@ -201,12 +201,13 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
static final OperationStepHandler DATA_SOURCE_TRANSLATOR = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!operation.hasDefined(JDBCStoreResourceDefinition.Attribute.DATA_SOURCE.getName())) {
if (operation.hasDefined(JDBCStoreResourceDefinition.DeprecatedAttribute.DATASOURCE.getName())) {
String targetAttributeName = JDBCStoreResourceDefinition.Attribute.DATA_SOURCE.getName();
if (!operation.hasDefined(targetAttributeName)) {
ModelNode jndiName = JDBCStoreResourceDefinition.DeprecatedAttribute.DATASOURCE.resolveModelAttribute(context, operation);
if (jndiName.isDefined()) {
// Translate JNDI name into pool name
String jndiName = JDBCStoreResourceDefinition.DeprecatedAttribute.DATASOURCE.resolveModelAttribute(context, operation).asString();
String poolName = findPoolName(context, jndiName);
operation.get(JDBCStoreResourceDefinition.Attribute.DATA_SOURCE.getName()).set(poolName);
String poolName = findPoolName(context, jndiName.asString());
operation.get(targetAttributeName).set(poolName);
} else {
throw ControllerLogger.MGMT_OP_LOGGER.validationFailedRequiredParameterNotPresent(JDBCStoreResourceDefinition.Attribute.DATA_SOURCE.getDefinition().getName(), operation.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static PathElement pathElement(String name) {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validatorBuilder) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, boolean defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, ModelType.BOOLEAN)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(new ModelNode(defaultValue))
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public AttributeDefinition getDefinition() {
static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
Expand All @@ -76,18 +76,18 @@ enum ColumnAttribute implements org.jboss.as.clustering.controller.Attribute {
ColumnAttribute(String name, String defaultName, String defaultType) {
this.name = new SimpleAttribute(new SimpleAttributeDefinitionBuilder("name", ModelType.STRING)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode(defaultName))
.build());
this.type = new SimpleAttribute(new SimpleAttributeDefinitionBuilder("type", ModelType.STRING)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode(defaultType))
.build());
this.definition = ObjectTypeAttributeDefinition.Builder.of(name, this.name.getDefinition(), this.type.getDefinition())
.setAllowNull(true)
.setRequired(false)
.setSuffix("column")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static PathElement pathElement(String name) {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validatorBuilder) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
Expand Down

0 comments on commit d3795ee

Please sign in to comment.