Class StandardResourceDescriptionResolver
- java.lang.Object
-
- org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver
-
- All Implemented Interfaces:
ResourceDescriptionResolver
- Direct Known Subclasses:
DeprecatedResourceDescriptionResolver,NonResolvingResourceDescriptionResolver
public class StandardResourceDescriptionResolver extends Object implements ResourceDescriptionResolver
ResourceBundlebasedResourceDescriptionResolverthat builds resource bundle keys by taking a "key prefix" provided to the constructor and dot-appending the string params to the variousgetXXXDescriptionmethods. 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 aResourceBundle.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
keyPrefixparam 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'sModelDescriptionConstants.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'sModelDescriptionConstants.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:
reuseAttributesForAddaffects how thegetOperationParameter...methods work. Iftrue, 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.
useUnprefixedChildTypesaffects how thegetChildTypeDescription(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. IfuseUnprefixedChildTypesistrue,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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringREPLYAdditional string dot-appended to the key by thegetOperationReplyDescription(String, Locale, ResourceBundle)method.
-
Constructor Summary
Constructors Constructor Description StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader)StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader, boolean reuseAttributesForAdd, boolean useUnprefixedChildTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetBundleKey(String... args)StandardResourceDescriptionResolvergetChildResolver(String key)StringgetChildTypeDescription(String childType, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's child types.StringgetKeyPrefix()StringgetNotificationDescription(String notificationType, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's notification.StringgetOperationDeprecatedDescription(String operationName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's operations.StringgetOperationDescription(String operationName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's operations.StringgetOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's operation's parameters.StringgetOperationParameterDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's operation's parameters.StringgetOperationParameterValueTypeDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle, String... suffixes)Gets the description of a portion of a complex value type of one of the resource's operation's parameters.StringgetOperationReplyDescription(String operationName, Locale locale, ResourceBundle bundle)Gets the description of the reply value for one of the resource's operations, ornullif there is no description.StringgetOperationReplyValueTypeDescription(String operationName, Locale locale, ResourceBundle bundle, String... suffixes)Gets the description of a portion of a complex value type of the reply value for one of the resource's operations, ornullif there is no description.StringgetResourceAttributeDeprecatedDescription(String attributeName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's attributes.StringgetResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle)Gets the description of one of the resource's attributes.StringgetResourceAttributeValueTypeDescription(String attributeName, Locale locale, ResourceBundle bundle, String... suffixes)Gets the description of a portion of a complex value type of one of the resource's attributes.ResourceBundlegetResourceBundle(Locale locale)Returns aResourceBundlefor the givenLocale, ornullif this resolver is not based on resource bundles.StringgetResourceDeprecatedDescription(Locale locale, ResourceBundle bundle)Gets the description of the resource.StringgetResourceDescription(Locale locale, ResourceBundle bundle)Gets the description of the resource.protected static StringgetVariableBundleKey(String prefix, String[] fixed, String... variable)Creates a resource entry key with key prefix, fixed parts, and variable parts.booleanisReuseAttributesForAdd()booleanisUseUnprefixedChildTypes()
-
-
-
Field Detail
-
REPLY
public static final String REPLY
Additional string dot-appended to the key by thegetOperationReplyDescription(String, Locale, ResourceBundle)method.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardResourceDescriptionResolver
public StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader)
-
StandardResourceDescriptionResolver
public StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader, boolean reuseAttributesForAdd, boolean useUnprefixedChildTypes)
-
-
Method Detail
-
getKeyPrefix
public String getKeyPrefix()
-
isReuseAttributesForAdd
public boolean isReuseAttributesForAdd()
-
isUseUnprefixedChildTypes
public boolean isUseUnprefixedChildTypes()
-
getChildResolver
public StandardResourceDescriptionResolver getChildResolver(String key)
-
getResourceBundle
public ResourceBundle getResourceBundle(Locale locale)
Returns aResourceBundlefor the givenLocale, ornullif this resolver is not based on resource bundles.This method will be invoked at least once before a series of invocations of the other methods in this interface, and the returned bundle will be passed to those methods as a parameter. The intent is to cache a resource bundle on the stack during the execution of all the methods needed to describe a resource or operation.
- Specified by:
getResourceBundlein interfaceResourceDescriptionResolver- Parameters:
locale- the locale- Returns:
- the resource bundle, or
null
-
getResourceDescription
public String getResourceDescription(Locale locale, ResourceBundle bundle)
Gets the description of the resource.- Specified by:
getResourceDescriptionin interfaceResourceDescriptionResolver- Parameters:
locale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getResourceAttributeDescription
public String getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's attributes.- Specified by:
getResourceAttributeDescriptionin interfaceResourceDescriptionResolver- Parameters:
attributeName- the name of the attributelocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getResourceAttributeValueTypeDescription
public String getResourceAttributeValueTypeDescription(String attributeName, Locale locale, ResourceBundle bundle, String... suffixes)
Gets the description of a portion of a complex value type of one of the resource's attributes.- Specified by:
getResourceAttributeValueTypeDescriptionin interfaceResourceDescriptionResolver- Parameters:
attributeName- the name of the attributelocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednullsuffixes- suffixes to dot-append to the base attribute key to generate a key- Returns:
- the localized description
-
getOperationDescription
public String getOperationDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operations.- Specified by:
getOperationDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getOperationParameterDescription
public String getOperationParameterDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.- Specified by:
getOperationParameterDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationparamName- the name of the operation's parameterlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getOperationParameterValueTypeDescription
public String getOperationParameterValueTypeDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle, String... suffixes)
Gets the description of a portion of a complex value type of one of the resource's operation's parameters.- Specified by:
getOperationParameterValueTypeDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationparamName- the name of the operation's parameterlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednullsuffixes- suffixes to dot-append to the base attribute key to generate a key- Returns:
- the localized description
-
getOperationReplyDescription
public String getOperationReplyDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of the reply value for one of the resource's operations, ornullif there is no description.- Specified by:
getOperationReplyDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description , or
null
-
getOperationReplyValueTypeDescription
public String getOperationReplyValueTypeDescription(String operationName, Locale locale, ResourceBundle bundle, String... suffixes)
Gets the description of a portion of a complex value type of the reply value for one of the resource's operations, ornullif there is no description.- Specified by:
getOperationReplyValueTypeDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednullsuffixes- suffixes to dot-append to the base attribute key to generate a key- Returns:
- the localized description , or
null
-
getNotificationDescription
public String getNotificationDescription(String notificationType, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's notification.- Specified by:
getNotificationDescriptionin interfaceResourceDescriptionResolver- Parameters:
notificationType- the type of the notificationlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getChildTypeDescription
public String getChildTypeDescription(String childType, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's child types.- Specified by:
getChildTypeDescriptionin interfaceResourceDescriptionResolver- Parameters:
childType- the name of the child typelocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getResourceDeprecatedDescription
public String getResourceDeprecatedDescription(Locale locale, ResourceBundle bundle)
Gets the description of the resource.- Specified by:
getResourceDeprecatedDescriptionin interfaceResourceDescriptionResolver- Parameters:
locale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getResourceAttributeDeprecatedDescription
public String getResourceAttributeDeprecatedDescription(String attributeName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's attributes.- Specified by:
getResourceAttributeDeprecatedDescriptionin interfaceResourceDescriptionResolver- Parameters:
attributeName- the name of the attributelocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getOperationDeprecatedDescription
public String getOperationDeprecatedDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operations.- Specified by:
getOperationDeprecatedDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getOperationParameterDeprecatedDescription
public String getOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.- Specified by:
getOperationParameterDeprecatedDescriptionin interfaceResourceDescriptionResolver- Parameters:
operationName- the name of the operationparamName- the name of the operation's parameterlocale- the localebundle- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale), ornullif that call returnednull- Returns:
- the localized description
-
getVariableBundleKey
protected static String getVariableBundleKey(String prefix, String[] fixed, String... variable)
Creates a resource entry key with key prefix, fixed parts, and variable parts. This method is declared static so that a caller can call it with any prefix, which may be different from the prefix associated with any instances of this class.- Parameters:
prefix- the key fixfixed- the fixed parts for the keyvariable- the variable parts for the key- Returns:
- a key with all the above parts
-
-