@ThreadSafe public final class LoadingMessageSourceProvider extends Object implements MessageSourceProvider
This class uses a MessageSourceLoader
internally to look up
message sources. As is the case for StaticMessageSourceProvider
, you
can also set a default source if the loader fails to grab a source.
Apart from the loader, you can customize two aspects of the provider:
Note that the expiry time is periodic only, and not per source. The loading result (success or failure) is recorded permanently until the expiry time kicks in.
In the event of a timeout, the task remains active until it gets a result; this means, for instance, that if you set up a timeout of 500 milliseconds, but the task takes 2 seconds to complete, during these two seconds, the default source will be returned instead.
You can also configure a loader so that it never expires.
You cannot instantiate that class directly; use newBuilder()
to
obtain a builder class and set up your provider.
LoadingMessageSourceProvider.Builder
Modifier and Type | Class and Description |
---|---|
static class |
LoadingMessageSourceProvider.Builder
Builder class for a
LoadingMessageSourceProvider |
Modifier and Type | Method and Description |
---|---|
MessageSource |
getMessageSource(Locale locale)
Provide a message source for a given locale
|
static LoadingMessageSourceProvider.Builder |
newBuilder()
Create a new builder
|
public static LoadingMessageSourceProvider.Builder newBuilder()
public MessageSource getMessageSource(Locale locale)
MessageSourceProvider
getMessageSource
in interface MessageSourceProvider
locale
- the localenull
if none is found