Class MapAttributeDefinition

java.lang.Object
org.jboss.as.controller.AttributeDefinition
org.jboss.as.controller.MapAttributeDefinition
All Implemented Interfaces:
Feature
Direct Known Subclasses:
ObjectMapAttributeDefinition, PropertiesAttributeDefinition, SimpleMapAttributeDefinition

public abstract class MapAttributeDefinition extends AttributeDefinition
Defining characteristics of an ModelType.OBJECT attribute in a Resource, where all children of the object have values of the same type; i.e. the attribute represents a logical map of arbitrary key value pairs.
Author:
Brian Stansberry (c) 2011 Red Hat Inc.
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      public org.jboss.dmr.ModelNode parse(String value, Location location) throws XMLStreamException
      Creates and returns a ModelNode using the given value after first validating the node against this object's validator.

      If value is null and a default value is available, the value of that default value will be used.

      Parameters:
      value - the value. Will be trimmed before use if not null.
      location - current location of the parser's XMLStreamReader. Used for any exception message
      Returns:
      ModelNode representing the parsed value
      Throws:
      XMLStreamException - if value is not valid
    • parseAndAddParameterElement

      public void parseAndAddParameterElement(String key, String value, org.jboss.dmr.ModelNode operation, org.jboss.staxmapper.XMLExtendedStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • addResourceAttributeDescription

      public org.jboss.dmr.ModelNode addResourceAttributeDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode resourceDescription)
      Description copied from class: AttributeDefinition
      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.
      Overrides:
      addResourceAttributeDescription in class AttributeDefinition
      Parameters:
      bundle - resource bundle to use for text descriptions
      prefix - prefix to prepend to the attribute name key when looking up descriptions
      resourceDescription - the overall resource description
      Returns:
      the attribute description node
    • addOperationParameterDescription

      public org.jboss.dmr.ModelNode addOperationParameterDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode operationDescription)
      Description copied from class: AttributeDefinition
      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.
      Overrides:
      addOperationParameterDescription in class AttributeDefinition
      Parameters:
      bundle - resource bundle to use for text descriptions
      prefix - prefix to prepend to the attribute name key when looking up descriptions
      operationDescription - the overall resource description
      Returns:
      the attribute description node
    • getElementValidator

      public ParameterValidator getElementValidator()
      The validator used to validate values in the map.
      Returns:
      the element validator
    • addValueTypeDescription

      protected abstract void addValueTypeDescription(org.jboss.dmr.ModelNode node, ResourceBundle bundle)
    • addResourceAttributeDescription

      public org.jboss.dmr.ModelNode addResourceAttributeDescription(org.jboss.dmr.ModelNode resourceDescription, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
      Description copied from class: AttributeDefinition
      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.
      Overrides:
      addResourceAttributeDescription in class AttributeDefinition
      Parameters:
      resourceDescription - the overall resource description
      resolver - provider of localized text descriptions
      locale - locale to pass to the resolver
      bundle - bundle to pass to the resolver
      Returns:
      the attribute description node
    • addAttributeValueTypeDescription

      protected abstract void addAttributeValueTypeDescription(org.jboss.dmr.ModelNode result, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
    • addOperationParameterDescription

      public org.jboss.dmr.ModelNode addOperationParameterDescription(org.jboss.dmr.ModelNode resourceDescription, String operationName, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
      Description copied from class: AttributeDefinition
      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.
      Overrides:
      addOperationParameterDescription in class AttributeDefinition
      Parameters:
      resourceDescription - the overall resource description
      operationName - the operation name
      resolver - provider of localized text descriptions
      locale - locale to pass to the resolver
      bundle - bundle to pass to the resolver
      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)
      Description copied from class: AttributeDefinition
      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.
      Overrides:
      addOperationReplyDescription in class AttributeDefinition
      Parameters:
      resourceDescription - the overall resource description
      operationName - the operation name
      resolver - provider of localized text descriptions
      locale - locale to pass to the resolver
      bundle - bundle to pass to the resolver
      Returns:
      the attribute description node
    • addOperationParameterValueTypeDescription

      protected abstract void addOperationParameterValueTypeDescription(org.jboss.dmr.ModelNode result, String operationName, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
    • marshallAsElement

      public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
      Description copied from class: AttributeDefinition
      Marshalls the value from the given resourceModel as an xml element, if it is marshallable.
      Overrides:
      marshallAsElement in class AttributeDefinition
      Parameters:
      resourceModel - the model, a non-null node of ModelType.OBJECT.
      marshallDefault - true if the value should be marshalled even if it matches the default value
      writer - stream writer to use for writing the attribute
      Throws:
      XMLStreamException - if thrown by writer
    • convertParameterExpressions

      protected org.jboss.dmr.ModelNode convertParameterExpressions(org.jboss.dmr.ModelNode parameter)
      Iterates through the items in the parameter map, calling convertParameterElementExpressions(ModelNode) for each value.

      Note that the default implementation of convertParameterElementExpressions(ModelNode) will only convert simple ModelType.STRING values. If users need to handle complex values with embedded expressions, they should use a subclass that overrides that method.

      Examine the given operation parameter value for any expression syntax, converting the relevant node to ModelType.EXPRESSION if such is supported.

      This implementation checks if expressions are allowed and if so, calls AttributeDefinition.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.

      Overrides:
      convertParameterExpressions in class AttributeDefinition
      Parameters:
      parameter - the node to examine. Cannot not be null
      Returns:
      a node matching parameter but with expressions converted, or the original parameter if no conversion was performed. Will not return null
    • convertParameterElementExpressions

      protected org.jboss.dmr.ModelNode convertParameterElementExpressions(org.jboss.dmr.ModelNode parameterElementValue)
      Examine the given value item of a parameter map for any expression syntax, converting the relevant node to ModelType.EXPRESSION if such is supported.
      Parameters:
      parameterElementValue - the node to examine. Will not be null
      Returns:
      the parameter element value with expressions converted, or the original parameter if no conversion was performed. Cannot return null