Class StandardResourceDescriptionResolver

  • All Implemented Interfaces:
    ResourceDescriptionResolver
    Direct Known Subclasses:
    DeprecatedResourceDescriptionResolver, NonResolvingResourceDescriptionResolver, SubsystemResourceDescriptionResolver

    public class StandardResourceDescriptionResolver
    extends Object
    implements ResourceDescriptionResolver
    ResourceBundle based ResourceDescriptionResolver that builds resource bundle keys by taking a "key prefix" provided to the constructor and dot-appending the string params to the various getXXXDescription methods. The "key prefix" is associated with a particular resource and serves to provide a namespace for the resource's key's in the set of keys used by a ResourceBundle.

    Code that uses this class to localize text descriptions should store their text description in a properties file whose keys follow the following format, where "prefix" is the keyPrefix param passed to the constructor, "attribute-name" is the name of an attribute, "operation-name" is the name of an operation, "param-name" is the name of a parameter to an operation, "child-type" is the name of one of the resource's valid child types, and "value-type-suffix" is the name of some detail element in a parameter, attribute or operation reply value that has a complex type.

    prefix=The description of the resource prefix.attribute-name=The description of one of the resource's attributes. prefix.attribute-name.value-type-suffix=The description of an element in a complex attribute's ModelDescriptionConstants.VALUE_TYPE. prefix.operation-name=The description of one of the resource's operations. prefix.operation-name.param-name=The description of one of an operation's parameters. prefix.operation-name.param-name.value-type-suffix=The description of an element in a complex operation parameter's ModelDescriptionConstants.VALUE_TYPE. prefix.operation-name.reply=The description of an operation's reply value. prefix.operation-name.reply.value-type-suffix=The description of an element in a complex operation reply value's ModelDescriptionConstants.VALUE_TYPE. prefix.child-type=The description of one of the resource's child resource types.

    The constructor supports two settings designed to help minimize the need for redundant entries in the properties file:

    1. reuseAttributesForAdd affects how the getOperationParameter... methods work. If true, the assumption is that for an operation named "add" the text description of a parameter will be the same as the description of an attribute of the same name. This would allow the properties for this example resource:

      pool.min-size=The minimum pool size. pool.max-size=The maximum pool size. pool.add.min-size=The minimum pool size. pool.add.max-size=The maximum pool size.

      To be reduced to:

      pool.min-size=The minimum pool size. pool.max-size=The maximum pool size.

    2. useUnprefixedChildTypes affects how the getChildTypeDescription(String, Locale, ResourceBundle) method works. The descriptions of a set of related resources need to include a description in the parent resource of its relationship to the child resource, as well as the description of the child resource itself. These two descriptions are often included in the same properties file and may be the exact same text. If useUnprefixedChildTypes is true, getChildTypeDescription(...) will assume there is an entry in the properties file that exactly matches the name of the child type. This would allow the properties for this example set of resources:

      subsystem=The foo subsystem. ... attributes and operations of the "subsystem" resource subsystem.connector=A connector that can be used to access the foo. connector=A connector that can be used to access the foo. ... attributes and operations of the "connector" resource

      To be reduced to:

      subsystem=The foo subsystem. ... attributes and operations of the "subsystem" resource connector=A connector that can be used to access the foo. connector=A connector that can be used to access the foo. ... attributes and operations of the "connector" resource

      Note that while this kind of usage is convenient, it often results in slightly lower quality descriptions. For example, in the example above, a better description for "subsystem.connector" is "The connectors that can be used to access the foo."

    Author:
    Brian Stansberry (c) 2011 Red Hat Inc.