Class StandardResourceDescriptionResolver
- java.lang.Object
-
- org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver
-
- All Implemented Interfaces:
ResourceDescriptionResolver
- Direct Known Subclasses:
DeprecatedResourceDescriptionResolver
,NonResolvingResourceDescriptionResolver
,SubsystemResourceDescriptionResolver
public class StandardResourceDescriptionResolver extends Object implements ResourceDescriptionResolver
ResourceBundle
basedResourceDescriptionResolver
that builds resource bundle keys by taking a "key prefix" provided to the constructor and dot-appending the string params to the variousgetXXXDescription
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 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
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'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:
reuseAttributesForAdd
affects 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.
useUnprefixedChildTypes
affects 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. IfuseUnprefixedChildTypes
istrue
,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 String
REPLY
Additional 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 String
getBundleKey(String... args)
StandardResourceDescriptionResolver
getChildResolver(String key)
String
getChildTypeDescription(String childType, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's child types.String
getKeyPrefix()
String
getNotificationDescription(String notificationType, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's notification.String
getOperationDeprecatedDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operations.String
getOperationDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operations.String
getOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.String
getOperationParameterDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.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.String
getOperationReplyDescription(String operationName, Locale locale, ResourceBundle bundle)
Gets the description of the reply value for one of the resource's operations, ornull
if there is no description.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, ornull
if there is no description.String
getResourceAttributeDeprecatedDescription(String attributeName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's attributes.String
getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle)
Gets the description of one of the resource's attributes.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.ResourceBundle
getResourceBundle(Locale locale)
Returns aResourceBundle
for the givenLocale
, ornull
if this resolver is not based on resource bundles.String
getResourceDeprecatedDescription(Locale locale, ResourceBundle bundle)
Gets the description of the resource.String
getResourceDescription(Locale locale, ResourceBundle bundle)
Gets the description of the resource.protected static String
getVariableBundleKey(String prefix, String[] fixed, String... variable)
Creates a resource entry key with key prefix, fixed parts, and variable parts.boolean
isReuseAttributesForAdd()
boolean
isUseUnprefixedChildTypes()
-
-
-
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 aResourceBundle
for the givenLocale
, ornull
if 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:
getResourceBundle
in 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:
getResourceDescription
in interfaceResourceDescriptionResolver
- Parameters:
locale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getResourceAttributeDescription
in interfaceResourceDescriptionResolver
- Parameters:
attributeName
- the name of the attributelocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getResourceAttributeValueTypeDescription
in interfaceResourceDescriptionResolver
- Parameters:
attributeName
- the name of the attributelocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if that call returnednull
suffixes
- 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:
getOperationDescription
in interfaceResourceDescriptionResolver
- Parameters:
operationName
- the name of the operationlocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getOperationParameterDescription
in 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)
, ornull
if 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:
getOperationParameterValueTypeDescription
in 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)
, ornull
if that call returnednull
suffixes
- 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, ornull
if there is no description.- Specified by:
getOperationReplyDescription
in interfaceResourceDescriptionResolver
- Parameters:
operationName
- the name of the operationlocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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, ornull
if there is no description.- Specified by:
getOperationReplyValueTypeDescription
in interfaceResourceDescriptionResolver
- Parameters:
operationName
- the name of the operationlocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if that call returnednull
suffixes
- 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:
getNotificationDescription
in interfaceResourceDescriptionResolver
- Parameters:
notificationType
- the type of the notificationlocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getChildTypeDescription
in interfaceResourceDescriptionResolver
- Parameters:
childType
- the name of the child typelocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if that call returnednull
- Returns:
- the localized description
-
getResourceDeprecatedDescription
public String getResourceDeprecatedDescription(Locale locale, ResourceBundle bundle)
Gets the description of the resource.- Specified by:
getResourceDeprecatedDescription
in interfaceResourceDescriptionResolver
- Parameters:
locale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getResourceAttributeDeprecatedDescription
in interfaceResourceDescriptionResolver
- Parameters:
attributeName
- the name of the attributelocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getOperationDeprecatedDescription
in interfaceResourceDescriptionResolver
- Parameters:
operationName
- the name of the operationlocale
- the localebundle
- a resource bundle previously obtained from a call toResourceDescriptionResolver.getResourceBundle(java.util.Locale)
, ornull
if 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:
getOperationParameterDeprecatedDescription
in 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)
, ornull
if 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
-
-