registration.registerReadOnlyAttribute(InterfaceDefinition.NAME, ReadResourceNameOperationStepHandler.INSTANCE);
}
@Deprecated
private static AttributeDefinition createNestedComplexType(final String name) {
return new AttributeDefinition(name, name, null, ModelType.OBJECT, true, false, MeasurementUnit.NONE, createNestedParamValidator(), ALTERNATIVES_ANY, null, AttributeAccess.Flag.RESTART_ALL_SERVICES) {
@Override
public ModelNode addResourceAttributeDescription(final ResourceBundle bundle, final String prefix, final ModelNode resourceDescription) {
final ModelNode result = super.addResourceAttributeDescription(bundle, prefix, resourceDescription);
addNestedDescriptions(result, prefix, bundle);
return result;
}
@Override
public ModelNode addOperationParameterDescription(ResourceBundle bundle, String prefix, ModelNode operationDescription) {
final ModelNode result = super.addOperationParameterDescription(bundle, prefix, operationDescription);
addNestedDescriptions(result, prefix, bundle);
return result;
}
@Override
public ModelNode addResourceAttributeDescription(ModelNode resourceDescription, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle) {
ModelNode result = super.addResourceAttributeDescription(resourceDescription, resolver, locale, bundle);
for (final AttributeDefinition def : NESTED_ATTRIBUTES) {
result.get(VALUE_TYPE, def.getName(), ModelDescriptionConstants.DESCRIPTION).set(resolver.getResourceAttributeDescription(def.getName(), locale, bundle));
}
return result;
}
@Override
public ModelNode addOperationParameterDescription(ModelNode resourceDescription, String operationName, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle) {
ModelNode result = super.addOperationParameterDescription(resourceDescription, operationName, resolver, locale, bundle);
for (final AttributeDefinition def : NESTED_ATTRIBUTES) {
result.get(VALUE_TYPE, def.getName(), ModelDescriptionConstants.DESCRIPTION).set(resolver.getOperationParameterDescription(operationName, def.getName(), locale, bundle));
}
return result;
}
void addNestedDescriptions(final ModelNode result, final String prefix, final ResourceBundle bundle) {
for (final AttributeDefinition def : NESTED_ATTRIBUTES) {
final String bundleKey = prefix == null ? def.getName() : (prefix + "." + def.getName());
result.get(VALUE_TYPE, def.getName(), ModelDescriptionConstants.DESCRIPTION).set(bundle.getString(bundleKey));
}
}
@Override
public ModelNode getNoTextDescription(boolean forOperation) {
final ModelNode model = super.getNoTextDescription(forOperation);
final ModelNode valueType = model.get(VALUE_TYPE);
for (final AttributeDefinition def : NESTED_ATTRIBUTES) {
final AttributeDefinition current;
if (NESTED_LIST_ATTRIBUTES.contains(def)) {
current = wrapAsList(def);
} else {
current = def;
}
final ModelNode m = current.getNoTextDescription(forOperation);
m.remove(ALTERNATIVES);
valueType.get(current.getName()).set(m);
}
return model;
}
};