Package io.micronaut.context.i18n
Class ResourceBundleMessageSource
java.lang.Object
io.micronaut.context.AbstractMessageSource
io.micronaut.context.i18n.ResourceBundleMessageSource
- All Implemented Interfaces:
MessageSource
,Ordered
A message source backed by a resource bundle.
- Since:
- 1.2
- Author:
- graemerocher
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.context.AbstractMessageSource
AbstractMessageSource.MessageKey
Nested classes/interfaces inherited from interface io.micronaut.context.MessageSource
MessageSource.MessageContext
-
Field Summary
Fields inherited from interface io.micronaut.context.MessageSource
EMPTY
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionResourceBundleMessageSource
(@NonNull String baseName) Default constructor.ResourceBundleMessageSource
(@NonNull String baseName, @Nullable Locale defaultLocale) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionBuild the cache used to store resolved bundles.protected @NonNull Map<AbstractMessageSource.MessageKey,
Optional<String>> Build the cache used to store resolved messages.protected ClassLoader
The class loader to use.getRawMessage
(@NonNull String code, @NonNull MessageSource.MessageContext context) Resolve a message for the given code and context.Methods inherited from class io.micronaut.context.AbstractMessageSource
interpolate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.MessageSource
getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getRawMessage, getRequiredMessage, getRequiredRawMessage
-
Constructor Details
-
ResourceBundleMessageSource
Default constructor.- Parameters:
baseName
- The base name of the message bundle
-
ResourceBundleMessageSource
public ResourceBundleMessageSource(@NonNull @NonNull String baseName, @Nullable @Nullable Locale defaultLocale) Default constructor.- Parameters:
baseName
- The base name of the message bundledefaultLocale
- The default locale to use if no message is found for the given locale
-
-
Method Details
-
getRawMessage
@NonNull public @NonNull Optional<String> getRawMessage(@NonNull @NonNull String code, @NonNull @NonNull MessageSource.MessageContext context) Description copied from interface:MessageSource
Resolve a message for the given code and context.- Parameters:
code
- The codecontext
- The context- Returns:
- A message if present
-
getClassLoader
The class loader to use.- Returns:
- The classloader
-
buildMessageCache
@NonNull protected @NonNull Map<AbstractMessageSource.MessageKey,Optional<String>> buildMessageCache()Build the cache used to store resolved messages.- Returns:
- The cache.
-
buildBundleCache
@NonNull protected @NonNull Map<AbstractMessageSource.MessageKey,Optional<ResourceBundle>> buildBundleCache()Build the cache used to store resolved bundles.- Returns:
- The cache.
-