Class AttributeDefinition
- java.lang.Object
-
- org.jboss.as.controller.AttributeDefinition
-
- Direct Known Subclasses:
ListAttributeDefinition
,MapAttributeDefinition
,SimpleAttributeDefinition
public abstract class AttributeDefinition extends Object
Defining characteristics of an attribute in aResource
or a parameter or reply value type field in anOperationDefinition
, with utility methods for validation.- Author:
- Brian Stansberry (c) 2011 Red Hat Inc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AttributeDefinition.NameAndGroup
SimpleComparable
that encapsulates the name of an attribute and any attribute group, ordering first one group (null group first) and then one attribute name.
-
Field Summary
Fields Modifier and Type Field Description protected static Set<org.jboss.dmr.ModelType>
COMPLEX_TYPES
TheModelType
types that reflect complex DMR structures --LIST
,OBJECT
,PROPERTY
}
-
Constructor Summary
Constructors Modifier Constructor Description protected
AttributeDefinition(AbstractAttributeDefinitionBuilder<?,?> toCopy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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, Resource resource, org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, add capability requirements.void
addCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
Deprecated.use @{linkaddCapabilityRequirements(OperationContext, Resource, ModelNode)
} variantorg.jboss.dmr.ModelNode
addDeprecatedInfo(org.jboss.dmr.ModelNode model)
Adds attribute deprecation information, if relevant, to the given attribute description nodeorg.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
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
addOperationReplyDescription(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
addOperationReplyDescription(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
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.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.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 toModelType.EXPRESSION
if such is supported.protected static org.jboss.dmr.ModelNode
convertStringExpression(org.jboss.dmr.ModelNode node)
Checks if the given node is ofModelType.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 thevalue corrector
is notnull
.List<AccessConstraintDefinition>
getAccessConstraints()
List<org.jboss.dmr.ModelNode>
getAllowedValues()
returns array with all allowed valuesString[]
getAlternatives()
Gets the names of other attributes whose value must beundefined
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 givenResourceBundle
for the attribute.String
getAttributeGroup()
Gets the name of the attribute group with which this attribute is associated, if any.AttributeMarshaller
getAttributeMarshaller()
Deprecated.usegetMarshaller()
String
getAttributeTextDescription(ResourceBundle bundle, String prefix)
Gets localized text from the givenResourceBundle
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 anySet<AttributeAccess.Flag>
getFlags()
Returns an immutable set of anyflags
used to indicate special characteristics of the attributeAttributeMarshaller
getMarshaller()
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 textdescription
fields.AttributeParser
getParser()
protected CapabilityReferenceRecorder
getReferenceRecorder()
String[]
getRequires()
Gets the names of other attributes whose value must not beundefined
if this attribute's value is defined.org.jboss.dmr.ModelType
getType()
The expectedtype
of theModelNode
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 hasalternatives
configured and the givenoperationObject
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 ofhasAlternative(org.jboss.dmr.ModelNode)
.boolean
isAllowExpression()
Whether aModelNode
holding the value of this attribute can beModelType.EXPRESSION
.boolean
isAllowNull()
Deprecated.use eitherisRequired()
orisNillable()
depending on which provides the desired informationboolean
isDeprecated()
boolean
isMarshallable(org.jboss.dmr.ModelNode resourceModel)
Gets whether the givenresourceModel
has a value for this attribute that should be marshalled to XML.boolean
isMarshallable(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault)
Gets whether the givenresourceModel
has a value for this attribute that should be marshalled to XML.boolean
isNillable()
Whether aModelNode
holding the value of this attribute can beModelType.UNDEFINED
in any situation.boolean
isNullSignificant()
Gets whether an access control check is required to implicitly set an attribute toundefined
in a resource "add" operation.boolean
isRequired()
Whether aModelNode
holding the value of this attribute can beModelType.UNDEFINED
when all other attributes in the same overall model that arealternatives
of this attribute are undefined.boolean
isRequired(org.jboss.dmr.ModelNode operationObject)
Gets whether this attribute must be defined in the givenoperationObject
boolean
isResourceOnly()
Show if attribute is resource only which means it wont be part of add operations but only present on resourceboolean
isValidatingNull()
Deprecated.this is no longer configurable, so this getter may be removed in a future major release.void
marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer)
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
.void
marshallAsElement(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer)
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
.void
removeCapabilityRequirements(OperationContext context, Resource resource, org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, remove capability requirements.void
removeCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
Deprecated.org.jboss.dmr.ModelNode
resolveModelAttribute(ExpressionResolver resolver, org.jboss.dmr.ModelNode model)
Finds a value in the givenmodel
whose key matches this attribute'sname
, uses the givenresolver
toExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode)
resolve} it and validates it using this attribute'svalidator
.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 givenvalue
, resolves it using the givenresolver
and validates it using this attribute'svalidator
.org.jboss.dmr.ModelNode
resolveValue(OperationContext context, org.jboss.dmr.ModelNode value)
Takes the givenvalue
, resolves it using the givencontext
and validates it using this attribute'svalidator
.void
validateAndSet(org.jboss.dmr.ModelNode operationObject, org.jboss.dmr.ModelNode model)
org.jboss.dmr.ModelNode
validateOperation(org.jboss.dmr.ModelNode operationObject)
-
-
-
Field Detail
-
COMPLEX_TYPES
protected static final Set<org.jboss.dmr.ModelType> COMPLEX_TYPES
TheModelType
types that reflect complex DMR structures --LIST
,OBJECT
,PROPERTY
}
-
-
Constructor Detail
-
AttributeDefinition
protected AttributeDefinition(AbstractAttributeDefinitionBuilder<?,?> toCopy)
-
-
Method Detail
-
getName
public String getName()
The attribute's name in the management model.- Returns:
- the name. Will not be
null
-
getXmlName
public String getXmlName()
The attribute's name in the xml configuration. Not relevant for operation parameters and reply value types.- Returns:
- the name. Will not be
null
, although it may not be relevant
-
getType
public org.jboss.dmr.ModelType getType()
The expectedtype
of theModelNode
that holds the attribute data.- Returns:
- the type. Will not be
null
-
isRequired
public boolean isRequired()
Whether aModelNode
holding the value of this attribute can beModelType.UNDEFINED
when all other attributes in the same overall model that arealternatives
of this attribute are undefined.In a valid model an attribute that is required must be undefined if any alternative is defined, so this method should not be used for checking if it is valid for the attribute ever to have an undefined value. Use
isNillable()
for that.- Returns:
true
if anundefined ModelNode
is invalid in the absence of alternatives;false
if not
-
isAllowNull
@Deprecated public boolean isAllowNull()
Deprecated.use eitherisRequired()
orisNillable()
depending on which provides the desired informationInverse ofisRequired()
.In a valid model an attribute that is required must be undefined if any alternative is defined, so this method should not be used for checking if it is valid for the attribute ever to have an undefined value. Use
isNillable()
for that.- Returns:
true
if anundefined ModelNode
is valid in the absence of alternatives;false
if not
-
isNillable
public boolean isNillable()
Whether aModelNode
holding the value of this attribute can beModelType.UNDEFINED
in any situation. An attribute that ordinarily isrequired
may still be undefined in a given model if analternative attribute
is defined.This is equivalent to
!isRequired() || (getAlternatives() != null && getAlternatives().length > 0)
.- Returns:
true
if anundefined ModelNode
is valid;false
if not
-
isNullSignificant
public final boolean isNullSignificant()
Gets whether an access control check is required to implicitly set an attribute toundefined
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 returnstrue
.Generally this is
true
ifundefined is allowed
and adefault value
exists, although some instances may have a different setting.- Returns:
true
if anundefined
value is significant
-
isAllowExpression
public boolean isAllowExpression()
Whether aModelNode
holding the value of this attribute can beModelType.EXPRESSION
.- Returns:
true
if anexpression ModelNode
is valid;false
if not
-
getDefaultValue
public org.jboss.dmr.ModelNode getDefaultValue()
Gets the default value to use for the attribute if a value was not provided.- Returns:
- the default value, or
null
if no defined value was provided
-
getAttributeGroup
public String getAttributeGroup()
Gets the name of the attribute group with which this attribute is associated, if any.- Returns:
- the name of the group, or
null
if the attribute is not associated with a group
-
getMeasurementUnit
public MeasurementUnit getMeasurementUnit()
The unit of measure in which an attribute with a numerical value is expressed.- Returns:
- the measurement unit, or
null
if none is relevant
-
getCorrector
public ParameterCorrector getCorrector()
Gets the corrector used to correct values before checking that they comply with the attribute's definition.- Returns:
- the corrector. May be
null
-
getValidator
public ParameterValidator getValidator()
Gets the validator used to validate that values comply with the attribute's definition.- Returns:
- the validator. Will not be
null
-
isValidatingNull
@Deprecated public boolean isValidatingNull()
Deprecated.this is no longer configurable, so this getter may be removed in a future major release.Gets whether the attribute definition is checking forundefined
values. This will betrue
for attributes that are notisRequired()
(although the validation is meaningless, since undefined is valid) and for required attributes that havealternatives
.Validation by the AttributeDefinition of required attributes with alternatives is not possible, as the necessary context of the overall change being made is not available.
- Returns:
true
if validation will check undefined values.
-
getAlternatives
public String[] getAlternatives()
Gets the names of other attributes whose value must beundefined
if this attribute's value is defined, and vice versa.- Returns:
- the alternative attribute names, or
null
if there are no such attributes
-
getRequires
public String[] getRequires()
Gets the names of other attributes whose value must not beundefined
if this attribute's value is defined.- Returns:
- the required attribute names, or
null
if there are no such attributes
-
getFlags
public Set<AttributeAccess.Flag> getFlags()
Returns an immutable set of anyflags
used to indicate special characteristics of the attribute- Returns:
- the flags. Will not be
null
but may be empty.
-
getAllowedValues
public List<org.jboss.dmr.ModelNode> getAllowedValues()
returns array with all allowed values- Returns:
- allowed values
-
isMarshallable
public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel)
Gets whether the givenresourceModel
has a value for this attribute that should be marshalled to XML.This is the same as
isMarshallable(resourceModel, true)
.- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.- Returns:
true
if the givenresourceModel
has a defined value under this attribute'sgetName()
() name}.
-
isMarshallable
public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault)
Gets whether the givenresourceModel
has a value for this attribute that should be marshalled to XML.- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.marshallDefault
-true
if the value should be marshalled even if it matches the default value- Returns:
true
if the givenresourceModel
has a defined value under this attribute'sgetName()
() name} andmarshallDefault
istrue
or that value differs from this attribute'sdefault value
.
-
validateOperation
public org.jboss.dmr.ModelNode validateOperation(org.jboss.dmr.ModelNode operationObject) throws OperationFailedException
Finds a value in the givenoperationObject
whose key matches this attribute'sname
and validates it using this attribute'svalidator
.- Parameters:
operationObject
- model node of typeModelType.OBJECT
, typically representing an operation request- Returns:
- the value
- Throws:
OperationFailedException
- if the value is not valid
-
validateAndSet
public final void validateAndSet(org.jboss.dmr.ModelNode operationObject, org.jboss.dmr.ModelNode model) throws OperationFailedException
Finds a value in the givenoperationObject
whose key matches this attribute'sname
, validates it using this attribute'svalidator
, and, stores it under this attribute's name in the givenmodel
.- Parameters:
operationObject
- model node of typeModelType.OBJECT
, typically representing an operation requestmodel
- model node in which the value should be stored- Throws:
OperationFailedException
- if the value is not valid
-
resolveModelAttribute
public org.jboss.dmr.ModelNode resolveModelAttribute(OperationContext context, org.jboss.dmr.ModelNode model) throws OperationFailedException
Finds a value in the givenmodel
whose key matches this attribute'sname
, uses the givencontext
toresolve
it and validates it using this attribute'svalidator
. If the value is undefined and adefault value
is available, the default value is used.- Parameters:
context
- the operation contextmodel
- model node of typeModelType.OBJECT
, typically representing a model resource- Returns:
- the resolved value, possibly the default value if the model does not have a defined value matching this attribute's name
- Throws:
OperationFailedException
- if the value is not valid
-
resolveModelAttribute
public org.jboss.dmr.ModelNode resolveModelAttribute(ExpressionResolver resolver, org.jboss.dmr.ModelNode model) throws OperationFailedException
Finds a value in the givenmodel
whose key matches this attribute'sname
, uses the givenresolver
toExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode)
resolve} it and validates it using this attribute'svalidator
. If the value is undefined and adefault value
is available, the default value is used.- Parameters:
resolver
- the expression resolvermodel
- model node of typeModelType.OBJECT
, typically representing a model resource- Returns:
- the resolved value, possibly the default value if the model does not have a defined value matching this attribute's name
- Throws:
OperationFailedException
- if the value is not valid
-
resolveValue
public org.jboss.dmr.ModelNode resolveValue(OperationContext context, org.jboss.dmr.ModelNode value) throws OperationFailedException
Takes the givenvalue
, resolves it using the givencontext
and validates it using this attribute'svalidator
. If the value is undefined and adefault value
is available, the default value is used.- Parameters:
context
- the context to use toresolve
the valuevalue
- a node that is expected to be a valid value for an attribute defined by this definition- Returns:
- the resolved value, possibly the default value if
value
is not defined - Throws:
OperationFailedException
- if the value is not valid
-
resolveValue
public org.jboss.dmr.ModelNode resolveValue(ExpressionResolver resolver, org.jboss.dmr.ModelNode value) throws OperationFailedException
Takes the givenvalue
, resolves it using the givenresolver
and validates it using this attribute'svalidator
. If the value is undefined and adefault value
is available, the default value is used.- Parameters:
resolver
- the expression resolvervalue
- a node that is expected to be a valid value for an attribute defined by this definition- Returns:
- the resolved value, possibly the default value if
value
is not defined - Throws:
OperationFailedException
- if the value is not valid
-
isAllowed
public boolean isAllowed(org.jboss.dmr.ModelNode operationObject)
Inverse ofhasAlternative(org.jboss.dmr.ModelNode)
.- Parameters:
operationObject
- an objectModelNode
whose keys are attribute names.- Returns:
true
ifoperationObject
has no defined values for attributes configured as our alternatives
-
isRequired
public boolean isRequired(org.jboss.dmr.ModelNode operationObject)
Gets whether this attribute must be defined in the givenoperationObject
- Parameters:
operationObject
- an objectModelNode
whose keys are attribute names.- Returns:
true
if this attribute isrequired
and the givenoperationObject
does not have any defined attributes configured asalternatives
to this attribute
-
hasAlternative
public boolean hasAlternative(org.jboss.dmr.ModelNode operationObject)
Gets whether this attribute hasalternatives
configured and the givenoperationObject
has any of those alternatives defined.- Parameters:
operationObject
- an objectModelNode
whose keys are attribute names.- Returns:
true
ifoperationObject
has any defined values for attributes configured as our alternatives
-
marshallAsElement
public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
.- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.writer
- stream writer to use for writing the attribute- Throws:
XMLStreamException
- if thrown bywriter
-
marshallAsElement
public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
.- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.marshallDefault
-true
if the value should be marshalled even if it matches the default valuewriter
- stream writer to use for writing the attribute- Throws:
XMLStreamException
- if thrown bywriter
-
addResourceAttributeDescription
public 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. The node describing the attribute is returned to make it easy to perform further modification.- Parameters:
bundle
- resource bundle to use for text descriptionsprefix
- prefix to prepend to the attribute name key when looking up descriptionsresourceDescription
- the overall resource description- Returns:
- the attribute description node
-
addResourceAttributeDescription
public 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. The node describing the attribute is returned to make it easy to perform further modification.- Parameters:
resourceDescription
- the overall resource descriptionresolver
- provider of localized text descriptionslocale
- locale to pass to the resolverbundle
- bundle to pass to the resolver- Returns:
- the attribute description node
-
addOperationParameterDescription
public 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. The node describing the parameter is returned to make it easy to perform further modification.- Parameters:
bundle
- resource bundle to use for text descriptionsprefix
- prefix to prepend to the attribute name key when looking up descriptionsoperationDescription
- the overall resource description- Returns:
- the attribute description node
-
addOperationParameterDescription
public 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. The node describing the parameter is returned to make it easy to perform further modification.- Parameters:
resourceDescription
- the overall resource descriptionoperationName
- the operation nameresolver
- provider of localized text descriptionslocale
- locale to pass to the resolverbundle
- bundle to pass to the resolver- Returns:
- the attribute description node
-
addOperationReplyDescription
public org.jboss.dmr.ModelNode addOperationReplyDescription(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. The node describing the parameter is returned to make it easy to perform further modification.- Parameters:
bundle
- resource bundle to use for text descriptionsprefix
- prefix to prepend to the attribute name key when looking up descriptionsoperationDescription
- the overall resource description- Returns:
- the attribute description node
-
addOperationReplyDescription
public org.jboss.dmr.ModelNode addOperationReplyDescription(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. The node describing the parameter is returned to make it easy to perform further modification.- Parameters:
resourceDescription
- the overall resource descriptionoperationName
- the operation nameresolver
- provider of localized text descriptionslocale
- locale to pass to the resolverbundle
- bundle to pass to the resolver- Returns:
- the attribute description node
-
getAttributeTextDescription
public String getAttributeTextDescription(ResourceBundle bundle, String prefix)
Gets localized text from the givenResourceBundle
for the attribute.- Parameters:
bundle
- the resource bundle. Cannot benull
prefix
- a prefix to dot-prepend to the attribute name to form a key to resolve in the bundle- Returns:
- the resolved text
-
getAttributeDeprecatedDescription
public String getAttributeDeprecatedDescription(ResourceBundle bundle, String prefix)
Gets localized deprecation text from the givenResourceBundle
for the attribute.- Parameters:
bundle
- the resource bundle. Cannot benull
prefix
- a prefix to dot-prepend to the attribute name to form a key to resolve in the bundle- Returns:
- the resolved text
-
addDeprecatedInfo
public org.jboss.dmr.ModelNode addDeprecatedInfo(org.jboss.dmr.ModelNode model)
Adds attribute deprecation information, if relevant, to the given attribute description node- Parameters:
model
- the attribute description- Returns:
- the node added to
model
ornull
if no deprecation data was needed
-
getNoTextDescription
public org.jboss.dmr.ModelNode getNoTextDescription(boolean forOperation)
Gets descriptive metadata for this attribute, excluding free-from textdescription
fields.- Parameters:
forOperation
-true
if the metadata is for an operation parameter or reply value type- Returns:
- object node containing the descriptive metadata
-
addCapabilityRequirements
@Deprecated public void addCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
Deprecated.use @{linkaddCapabilityRequirements(OperationContext, Resource, ModelNode)
} variantBased on the given attribute value, add capability requirements. If this definition is for an attribute whose value is or contains a reference to the name of some capability, this method should record the addition of a requirement for the capability.This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
- Parameters:
context
- the operation contextattributeValue
- the value of the attribute described by this object
-
addCapabilityRequirements
public void addCapabilityRequirements(OperationContext context, Resource resource, org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, add capability requirements. If this definition is for an attribute whose value is or contains a reference to the name of some capability, this method should record the addition of a requirement for the capability.This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
- Parameters:
context
- the operation contextresource
- the resource on which requirements are gatheredattributeValue
- the value of the attribute described by this object
-
removeCapabilityRequirements
@Deprecated public void removeCapabilityRequirements(OperationContext context, org.jboss.dmr.ModelNode attributeValue)
Deprecated.Based on the given attribute value, remove capability requirements. If this definition is for an attribute whose value is or contains a reference to the name of some capability, this method should record the removal of a requirement for the capability.This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
- Parameters:
context
- the operation contextattributeValue
- the value of the attribute described by this object
-
removeCapabilityRequirements
public void removeCapabilityRequirements(OperationContext context, Resource resource, org.jboss.dmr.ModelNode attributeValue)
Based on the given attribute value, remove capability requirements. If this definition is for an attribute whose value is or contains a reference to the name of some capability, this method should record the removal of a requirement for the capability.This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
- Parameters:
context
- the operation contextresource
- resource from which capability requirement is to be removed from,null
is legal value in case thatCapabilityReferenceRecorder
doesn't require it.attributeValue
- the value of the attribute described by this object
-
hasCapabilityRequirements
public boolean hasCapabilityRequirements()
Based on the given attribute value, tell if attribute has any capability requirements. If this definition is for an attribute whose value is or contains a reference to the name of some capability, this method will return true otherwise false.This is a no-op in this base class. Subclasses that support attribute types that can represent capability references should override this method.
- Returns:
true
if this definition is for an attribute whose value is or contains a reference to the name of some capability
-
getReferenceRecorder
protected CapabilityReferenceRecorder getReferenceRecorder()
-
addAllowedValuesToDescription
protected void addAllowedValuesToDescription(org.jboss.dmr.ModelNode result, ParameterValidator validator)
Adds the allowed values. Override for attributes who should not use the allowed values.- Parameters:
result
- the node to add the allowed values tovalidator
- the validator to get the allowed values from
-
correctValue
protected final org.jboss.dmr.ModelNode correctValue(org.jboss.dmr.ModelNode newValue, org.jboss.dmr.ModelNode oldValue)
Corrects the value if thevalue corrector
is notnull
. If thevalue corrector
isnull
, thenewValue
parameter is returned.- Parameters:
newValue
- the new value.oldValue
- the old value.- Returns:
- the corrected value or the
newValue
if thevalue corrector
isnull
.
-
convertParameterExpressions
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 toModelType.EXPRESSION
if such is supported.This implementation checks if
expressions are allowed
and if so, callsconvertStringExpression(ModelNode)
to convert aModelType.STRING
to aModelType.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 thecomplex DMR types
. If it is, anIllegalStateException
is thrown, as this implementation cannot properly handle such a combination, and a subclass that overrides this method should be used.- Parameters:
parameter
- the node to examine. Cannot not benull
- Returns:
- a node matching
parameter
but with expressions converted, or the original parameter if no conversion was performed. Will not returnnull
- Throws:
IllegalStateException
- if expressions are supported, but theattribute type
iscomplex
-
convertStringExpression
protected static org.jboss.dmr.ModelNode convertStringExpression(org.jboss.dmr.ModelNode node)
Checks if the given node is ofModelType.STRING
with a string value that includes expression syntax. If so returns a node ofModelType.EXPRESSION
, else simply returnsnode
unchanged- Parameters:
node
- the node to examine. Will not benull
- Returns:
- the node with expressions converted, or the original node if no conversion was performed
Cannot return
null
-
getAttributeMarshaller
@Deprecated public AttributeMarshaller getAttributeMarshaller()
Deprecated.usegetMarshaller()
- Returns:
- AttributeMarshaller that provides means to marshal attribute to xml
-
getMarshaller
public AttributeMarshaller getMarshaller()
- Returns:
- attribute marshaller that can be used to persist attribute to XML
-
isResourceOnly
public boolean isResourceOnly()
Show if attribute is resource only which means it wont be part of add operations but only present on resource- Returns:
- true is attribute is resource only
-
isDeprecated
public boolean isDeprecated()
- Returns:
- true if attribute is deprecated
-
getDeprecationData
public DeprecationData getDeprecationData()
return deprecation data if there is any- Returns:
DeprecationData
-
getAccessConstraints
public List<AccessConstraintDefinition> getAccessConstraints()
-
addAccessConstraints
protected void addAccessConstraints(org.jboss.dmr.ModelNode result, Locale locale)
-
getParser
public AttributeParser getParser()
-
getUndefinedMetricValue
public org.jboss.dmr.ModelNode getUndefinedMetricValue()
Gets the undefined metric value to use for the attribute if a value cannot be provided.- Returns:
- the undefined metric value, or
null
if no undefined metric value was provided
-
-