public abstract class AttributeDefinition extends Object
Resource or a
parameter or reply value type field in an OperationDefinition, with utility
methods for validation.| Modifier and Type | Class and Description |
|---|---|
static class |
AttributeDefinition.NameAndGroup
Simple
Comparable that encapsulates the name of an attribute and any attribute group,
ordering first one group (null group first) and then one attribute name. |
| Modifier and Type | Field and Description |
|---|---|
protected AttributeMarshaller |
attributeMarshaller |
protected static Set<org.jboss.dmr.ModelType> |
COMPLEX_TYPES
The
ModelType types that reflect complex DMR structures -- LIST, OBJECT, PROPERTY} |
protected CapabilityReferenceRecorder |
referenceRecorder |
| Modifier | Constructor and Description |
|---|---|
protected |
AttributeDefinition(AbstractAttributeDefinitionBuilder<?,?> toCopy) |
protected |
AttributeDefinition(String name,
String xmlName,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
boolean allowExpression,
MeasurementUnit measurementUnit,
ParameterCorrector valueCorrector,
ParameterValidator validator,
boolean validateNull,
String[] alternatives,
String[] requires,
AttributeMarshaller attributeMarshaller,
boolean resourceOnly,
DeprecationData deprecationData,
AccessConstraintDefinition[] accessConstraints,
Boolean nilSignificant,
AttributeParser parser,
AttributeAccess.Flag... flags) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAccessConstraints(org.jboss.dmr.ModelNode result,
Locale locale) |
protected void |
addAllowedValuesToDescription(org.jboss.dmr.ModelNode result,
ParameterValidator validator)
Adds the allowed values.
|
void |
addCapabilityRequirements(OperationContext context,
org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, add capability requirements.
|
org.jboss.dmr.ModelNode |
addDeprecatedInfo(org.jboss.dmr.ModelNode model)
Adds attribute deprecation information, if relevant, to the given attribute description node
|
org.jboss.dmr.ModelNode |
addOperationParameterDescription(org.jboss.dmr.ModelNode resourceDescription,
String operationName,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
Creates a returns a basic model node describing a parameter that sets this attribute, after attaching it to the
given overall operation description model node.
|
org.jboss.dmr.ModelNode |
addOperationParameterDescription(ResourceBundle bundle,
String prefix,
org.jboss.dmr.ModelNode operationDescription)
Creates a returns a basic model node describing a parameter that sets this attribute, after attaching it to the
given overall operation description model node.
|
org.jboss.dmr.ModelNode |
addResourceAttributeDescription(org.jboss.dmr.ModelNode resourceDescription,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
Creates a returns a basic model node describing the attribute, after attaching it to the given overall resource
description model node.
|
org.jboss.dmr.ModelNode |
addResourceAttributeDescription(ResourceBundle bundle,
String prefix,
org.jboss.dmr.ModelNode resourceDescription)
Creates a returns a basic model node describing the attribute, after attaching it to the given overall resource
description model node.
|
protected org.jboss.dmr.ModelNode |
convertParameterExpressions(org.jboss.dmr.ModelNode parameter)
Examine the given operation parameter value for any expression syntax, converting the relevant node to
ModelType.EXPRESSION if such is supported. |
protected static org.jboss.dmr.ModelNode |
convertStringExpression(org.jboss.dmr.ModelNode node)
Checks if the given node is of
ModelType.STRING with a string value that includes expression syntax. |
protected org.jboss.dmr.ModelNode |
correctValue(org.jboss.dmr.ModelNode newValue,
org.jboss.dmr.ModelNode oldValue)
Corrects the value if the
value corrector is not null. |
List<AccessConstraintDefinition> |
getAccessConstraints() |
List<org.jboss.dmr.ModelNode> |
getAllowedValues()
returns array with all allowed values
|
String[] |
getAlternatives()
Gets the names of other attributes whose value must be
undefined if this attribute's value is
defined, and vice versa. |
Map<String,org.jboss.dmr.ModelNode> |
getArbitraryDescriptors() |
String |
getAttributeDeprecatedDescription(ResourceBundle bundle,
String prefix)
Gets localized deprecation text from the given
ResourceBundle for the attribute. |
String |
getAttributeGroup()
Gets the name of the attribute group with which this attribute is associated, if any.
|
AttributeMarshaller |
getAttributeMarshaller() |
String |
getAttributeTextDescription(ResourceBundle bundle,
String prefix)
Gets localized text from the given
ResourceBundle for the attribute. |
ParameterCorrector |
getCorrector()
Gets the corrector used to correct values before checking that they comply with the attribute's definition.
|
org.jboss.dmr.ModelNode |
getDefaultValue()
Gets the default value to use for the attribute if a value was not provided.
|
DeprecationData |
getDeprecationData()
return deprecation data if there is any
|
EnumSet<AttributeAccess.Flag> |
getFlags()
Gets any
flags used to indicate special
characteristics of the attribute |
MeasurementUnit |
getMeasurementUnit()
The unit of measure in which an attribute with a numerical value is expressed.
|
String |
getName()
The attribute's name in the management model.
|
org.jboss.dmr.ModelNode |
getNoTextDescription(boolean forOperation)
Gets descriptive metadata for this attribute, excluding free-from text
description fields. |
AttributeParser |
getParser() |
protected CapabilityReferenceRecorder |
getReferenceRecorder() |
String[] |
getRequires()
Gets the names of other attributes whose value must not be
undefined if this attribute's value is
defined. |
org.jboss.dmr.ModelType |
getType()
The expected
type of the ModelNode that holds the
attribute data. |
org.jboss.dmr.ModelNode |
getUndefinedMetricValue()
Gets the undefined metric value to use for the attribute if a value cannot be provided.
|
ParameterValidator |
getValidator()
Gets the validator used to validate that values comply with the attribute's definition.
|
String |
getXmlName()
The attribute's name in the xml configuration.
|
boolean |
hasAlternative(org.jboss.dmr.ModelNode operationObject)
Gets whether this attribute has
alternatives configured and the given
operationObject has any of those alternatives defined. |
boolean |
hasCapabilityRequirements()
Based on the given attribute value, tell if attribute has any capability requirements.
|
boolean |
isAllowed(org.jboss.dmr.ModelNode operationObject)
Inverse of
hasAlternative(org.jboss.dmr.ModelNode). |
boolean |
isAllowExpression()
Whether a
ModelNode holding the value of this attribute can be
ModelType.EXPRESSION. |
boolean |
isAllowNull()
Whether a
ModelNode holding the value of this attribute can be
ModelType.UNDEFINED. |
boolean |
isDeprecated() |
boolean |
isMarshallable(org.jboss.dmr.ModelNode resourceModel)
Gets whether the given
resourceModel has a value for this attribute that should be marshalled to XML. |
boolean |
isMarshallable(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault)
Gets whether the given
resourceModel has a value for this attribute that should be marshalled to XML. |
boolean |
isNullSignificant()
Gets whether an access control check is required to implicitly set an attribute to
undefined
in a resource "add" operation. |
boolean |
isRequired(org.jboss.dmr.ModelNode operationObject)
Gets whether this attribute must be defined in the given
operationObject |
boolean |
isResourceOnly()
Show if attribute is resource only which means it wont be part of add operations but only present on resource
|
boolean |
isValidatingNull()
Gets whether the attribute definition should check for
undefined values if
null is not allowed in addition to any validation provided by any
configured validator. |
void |
marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml element, if it
is marshallable. |
void |
marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml element, if it
is marshallable. |
void |
removeCapabilityRequirements(OperationContext context,
org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, remove capability requirements.
|
org.jboss.dmr.ModelNode |
resolveModelAttribute(ExpressionResolver resolver,
org.jboss.dmr.ModelNode model)
Finds a value in the given
model whose key matches this attribute's name,
uses the given resolver to ExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode) resolve}
it and validates it using this attribute's validator. |
org.jboss.dmr.ModelNode |
resolveModelAttribute(OperationContext context,
org.jboss.dmr.ModelNode model)
|
org.jboss.dmr.ModelNode |
resolveValue(ExpressionResolver resolver,
org.jboss.dmr.ModelNode value)
Takes the given
value, resolves it using the given resolver
and validates it using this attribute's validator. |
org.jboss.dmr.ModelNode |
resolveValue(OperationContext context,
org.jboss.dmr.ModelNode value)
Takes the given
value, resolves it using the given context
and validates it using this attribute's validator. |
void |
validateAndSet(org.jboss.dmr.ModelNode operationObject,
org.jboss.dmr.ModelNode model)
|
org.jboss.dmr.ModelNode |
validateOperation(org.jboss.dmr.ModelNode operationObject)
|
protected static final Set<org.jboss.dmr.ModelType> COMPLEX_TYPES
ModelType types that reflect complex DMR structures -- LIST, OBJECT, PROPERTY}protected final AttributeMarshaller attributeMarshaller
protected final CapabilityReferenceRecorder referenceRecorder
protected AttributeDefinition(AbstractAttributeDefinitionBuilder<?,?> toCopy)
protected AttributeDefinition(String name, String xmlName, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, boolean allowExpression, MeasurementUnit measurementUnit, ParameterCorrector valueCorrector, ParameterValidator validator, boolean validateNull, String[] alternatives, String[] requires, AttributeMarshaller attributeMarshaller, boolean resourceOnly, DeprecationData deprecationData, AccessConstraintDefinition[] accessConstraints, Boolean nilSignificant, AttributeParser parser, AttributeAccess.Flag... flags)
public String getName()
nullpublic String getXmlName()
null, although it may not be relevantpublic org.jboss.dmr.ModelType getType()
type of the ModelNode that holds the
attribute data.nullpublic boolean isAllowNull()
ModelNode holding the value of this attribute can be
ModelType.UNDEFINED.true if an undefined ModelNode is valid; false if notpublic boolean isNullSignificant()
undefined
in a resource "add" operation. "Implicitly" setting an attribute refers to not providing a value for
it in the add operation, leaving the attribute in an undefined state. So, if a user attempts to
add a resource but does not define some attributes, a write permission check will be performed for
any attributes where this method returns true.
Generally this is true if undefined is allowed and a
default value exists, although some instances may have a different setting.
true if an undefined value is significantpublic boolean isAllowExpression()
ModelNode holding the value of this attribute can be
ModelType.EXPRESSION.true if an expression ModelNode is valid; false if notpublic org.jboss.dmr.ModelNode getDefaultValue()
null if no defined value was providedpublic String getAttributeGroup()
null if the attribute is not associated with a grouppublic MeasurementUnit getMeasurementUnit()
null if none is relevantpublic ParameterCorrector getCorrector()
nullpublic ParameterValidator getValidator()
nullpublic boolean isValidatingNull()
undefined values if
null is not allowed in addition to any validation provided by any
configured validator. The use
case for setting this to false would be to ignore undefined values in the basic validation performed
by the AttributeDefinition and instead let operation handlers validate using more complex logic
(e.g. checking for alternatives.true if validation will ignore undefined values.public String[] getAlternatives()
undefined if this attribute's value is
defined, and vice versa.null if there are no such attributespublic String[] getRequires()
undefined if this attribute's value is
defined.null if there are no such attributespublic EnumSet<AttributeAccess.Flag> getFlags()
flags used to indicate special
characteristics of the attributenull but may be empty.public List<org.jboss.dmr.ModelNode> getAllowedValues()
public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel)
resourceModel has a value for this attribute that should be marshalled to XML.
This is the same as isMarshallable(resourceModel, true).
resourceModel - the model, a non-null node of ModelType.OBJECT.true if the given resourceModel has a defined value under this attribute's getName() () name}.public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault)
resourceModel has a value for this attribute that should be marshalled to XML.resourceModel - the model, a non-null node of ModelType.OBJECT.marshallDefault - true if the value should be marshalled even if it matches the default valuetrue if the given resourceModel has a defined value under this attribute's getName() () name}
and marshallDefault is true or that value differs from this attribute's default value.public org.jboss.dmr.ModelNode validateOperation(org.jboss.dmr.ModelNode operationObject)
throws OperationFailedException
operationObject whose key matches this attribute's name and
validates it using this attribute's validator.operationObject - model node of type ModelType.OBJECT, typically representing an operation requestOperationFailedException - if the value is not validpublic final void validateAndSet(org.jboss.dmr.ModelNode operationObject,
org.jboss.dmr.ModelNode model)
throws OperationFailedException
operationObject whose key matches this attribute's name,
validates it using this attribute's validator, and, stores it under this attribute's name in the given model.operationObject - model node of type ModelType.OBJECT, typically representing an operation requestmodel - model node in which the value should be storedOperationFailedException - if the value is not validpublic org.jboss.dmr.ModelNode resolveModelAttribute(OperationContext context, org.jboss.dmr.ModelNode model) throws OperationFailedException
model whose key matches this attribute's name,
uses the given context to resolve
it and validates it using this attribute's validator. If the value is
undefined and a default value is available, the default value is used.context - the operation contextmodel - model node of type ModelType.OBJECT, typically representing a model resourceOperationFailedException - if the value is not validpublic org.jboss.dmr.ModelNode resolveModelAttribute(ExpressionResolver resolver, org.jboss.dmr.ModelNode model) throws OperationFailedException
model whose key matches this attribute's name,
uses the given resolver to ExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode) resolve}
it and validates it using this attribute's validator. If the value is
undefined and a default value is available, the default value is used.resolver - the expression resolvermodel - model node of type ModelType.OBJECT, typically representing a model resourceOperationFailedException - if the value is not validpublic org.jboss.dmr.ModelNode resolveValue(OperationContext context, org.jboss.dmr.ModelNode value) throws OperationFailedException
value, resolves it using the given context
and validates it using this attribute's validator. If the value is
undefined and a default value is available, the default value is used.context - the context to use to resolve the valuevalue - a node that is expected to be a valid value for an attribute defined by this definitionvalue is not definedOperationFailedException - if the value is not validpublic org.jboss.dmr.ModelNode resolveValue(ExpressionResolver resolver, org.jboss.dmr.ModelNode value) throws OperationFailedException
value, resolves it using the given resolver
and validates it using this attribute's validator. If the value is
undefined and a default value is available, the default value is used.resolver - the expression resolvervalue - a node that is expected to be a valid value for an attribute defined by this definitionvalue is not definedOperationFailedException - if the value is not validpublic boolean isAllowed(org.jboss.dmr.ModelNode operationObject)
hasAlternative(org.jboss.dmr.ModelNode).operationObject - an object ModelNode whose keys are attribute names.true if operationObject has no defined values for attributes configured as our alternativespublic boolean isRequired(org.jboss.dmr.ModelNode operationObject)
operationObjectoperationObject - an object ModelNode whose keys are attribute names.true if this attribute does not allow null and the given
operationObject does not have any defined attributes configured as
alternatives to this attributepublic boolean hasAlternative(org.jboss.dmr.ModelNode operationObject)
alternatives configured and the given
operationObject has any of those alternatives defined.operationObject - an object ModelNode whose keys are attribute names.true if operationObject has any defined values for attributes configured as our alternativespublic void marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
XMLStreamWriter writer)
throws XMLStreamException
resourceModel as an xml element, if it
is marshallable.resourceModel - the model, a non-null node of ModelType.OBJECT.writer - stream writer to use for writing the attributeXMLStreamException - if thrown by writerpublic void marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault,
XMLStreamWriter writer)
throws XMLStreamException
resourceModel as an xml element, if it
is marshallable.resourceModel - the model, a non-null node of ModelType.OBJECT.marshallDefault - true if the value should be marshalled even if it matches the default valuewriter - stream writer to use for writing the attributeXMLStreamException - if thrown by writerpublic org.jboss.dmr.ModelNode addResourceAttributeDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode resourceDescription)
bundle - resource bundle to use for text descriptionsprefix - prefix to prepend to the attribute name key when looking up descriptionsresourceDescription - the overall resource descriptionpublic org.jboss.dmr.ModelNode addResourceAttributeDescription(org.jboss.dmr.ModelNode resourceDescription,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
resourceDescription - the overall resource descriptionresolver - provider of localized text descriptionslocale - locale to pass to the resolverbundle - bundle to pass to the resolverpublic org.jboss.dmr.ModelNode addOperationParameterDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode operationDescription)
bundle - resource bundle to use for text descriptionsprefix - prefix to prepend to the attribute name key when looking up descriptionsoperationDescription - the overall resource descriptionpublic org.jboss.dmr.ModelNode addOperationParameterDescription(org.jboss.dmr.ModelNode resourceDescription,
String operationName,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
resourceDescription - the overall resource descriptionoperationName - the operation nameresolver - provider of localized text descriptionslocale - locale to pass to the resolverbundle - bundle to pass to the resolverpublic String getAttributeTextDescription(ResourceBundle bundle, String prefix)
ResourceBundle for the attribute.bundle - the resource bundle. Cannot be nullprefix - a prefix to dot-prepend to the attribute name to form a key to resolve in the bundlepublic String getAttributeDeprecatedDescription(ResourceBundle bundle, String prefix)
ResourceBundle for the attribute.bundle - the resource bundle. Cannot be nullprefix - a prefix to dot-prepend to the attribute name to form a key to resolve in the bundlepublic org.jboss.dmr.ModelNode addDeprecatedInfo(org.jboss.dmr.ModelNode model)
model - the attribute descriptionmodel or null if no deprecation data was neededpublic org.jboss.dmr.ModelNode getNoTextDescription(boolean forOperation)
description fields.forOperation - true if the metadata is for an operation parameter
or reply value typepublic void addCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
context - the operation contextattributeValue - the value of the attribute described by this objectpublic void removeCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
context - the operation contextattributeValue - the value of the attribute described by this objectpublic boolean hasCapabilityRequirements()
This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
protected CapabilityReferenceRecorder getReferenceRecorder()
protected void addAllowedValuesToDescription(org.jboss.dmr.ModelNode result,
ParameterValidator validator)
result - the node to add the allowed values tovalidator - the validator to get the allowed values fromprotected final org.jboss.dmr.ModelNode correctValue(org.jboss.dmr.ModelNode newValue,
org.jboss.dmr.ModelNode oldValue)
value corrector is not null. If the value corrector is null, the newValue parameter is returned.newValue - the new value.oldValue - the old value.newValue if the value corrector is null.protected org.jboss.dmr.ModelNode convertParameterExpressions(org.jboss.dmr.ModelNode parameter)
ModelType.EXPRESSION if such is supported.
This implementation checks if expressions are allowed and if so, calls
convertStringExpression(ModelNode) to convert a ModelType.STRING to a ModelType.EXPRESSION.
No other conversions are performed. For use cases requiring more complex behavior, a subclass that overrides
this method should be used.
If expressions are supported this implementation also checks if the attribute type is one of
the complex DMR types. If it is, an IllegalStateException is thrown, as this
implementation cannot properly handle such a combination, and a subclass that overrides this method should be used.
parameter - the node to examine. Cannot not be nullparameter but with expressions converted, or the original parameter if no
conversion was performed. Will not return nullIllegalStateException - if expressions are supported, but the attribute type is complexprotected static org.jboss.dmr.ModelNode convertStringExpression(org.jboss.dmr.ModelNode node)
ModelType.STRING with a string value that includes expression syntax.
If so returns a node of ModelType.EXPRESSION, else simply returns node unchangednode - the node to examine. Will not be nullnullpublic AttributeMarshaller getAttributeMarshaller()
public boolean isResourceOnly()
public boolean isDeprecated()
public DeprecationData getDeprecationData()
DeprecationDatapublic List<AccessConstraintDefinition> getAccessConstraints()
protected void addAccessConstraints(org.jboss.dmr.ModelNode result,
Locale locale)
public AttributeParser getParser()
public org.jboss.dmr.ModelNode getUndefinedMetricValue()
null if no undefined metric value was providedCopyright © 2016 JBoss by Red Hat. All rights reserved.