public class CachingRepositoryResourceBundleMessageFormatProvider extends org.springframework.context.support.MessageSourceSupport implements RepositoryResourceBundleMessageFormatProvider
RepositoryResourceBundleMessageFormatProvider
implementation providing
MessageFormat
caching per ResourceBundle
, resource key and locale.
Also, it maintain the cache separately based on preview/live request context.Constructor and Description |
---|
CachingRepositoryResourceBundleMessageFormatProvider() |
Modifier and Type | Method and Description |
---|---|
protected Map<org.hippoecm.hst.util.KeyValue<String,Locale>,ResourceBundle> |
getBasenameLocaleBundles()
Test purpose getter.
|
protected Map<org.hippoecm.hst.util.KeyValue<String,Locale>,ResourceBundle> |
getBasenameLocaleBundlesForPreview()
Test purpose getter.
|
protected Map<ResourceBundle,org.hippoecm.hst.util.KeyValue<String,Locale>> |
getBundleBasenameLocales()
Test purpose getter.
|
protected Map<ResourceBundle,org.hippoecm.hst.util.KeyValue<String,Locale>> |
getBundleBasenameLocalesForPreview()
Test purpose getter.
|
protected Map<ResourceBundle,Map<String,Map<Locale,MessageFormat>>> |
getCachedBundleMessageFormats()
Test purpose getter.
|
protected Map<ResourceBundle,Map<String,Map<Locale,MessageFormat>>> |
getCachedBundleMessageFormatsForPreview()
Test purpose getter.
|
MessageFormat |
getMessageFormat(ResourceBundle bundle,
String code,
Locale locale)
Return a MessageFormat for the given bundle and code,
fetching already generated MessageFormats from the cache.
|
void |
registerBundle(String basename,
Locale locale,
ResourceBundle bundle)
Register the live
bundle by the basename and locale
in order to be able to determine that the bundle was originated from repository. |
void |
registerPreviewBundle(String basename,
Locale locale,
ResourceBundle bundle)
Register the preview
bundle by the basename and locale
in order to be able to determine that the bundle was originated from repository. |
public CachingRepositoryResourceBundleMessageFormatProvider()
public void registerBundle(String basename, Locale locale, ResourceBundle bundle)
bundle
by the basename
and locale
in order to be able to determine that the bundle
was originated from repository.
Note: Whenever retrieve a resource bundle from repository, this method should be invoked.
Then this implementation should register it if not yet done or clear any outdated
cache associated with the basename
and locale
for a refreshed bundle.
registerBundle
in interface RepositoryResourceBundleMessageFormatProvider
basename
- resource bundle basenamelocale
- resource bundle localebundle
- resource bundlepublic void registerPreviewBundle(String basename, Locale locale, ResourceBundle bundle)
bundle
by the basename
and locale
in order to be able to determine that the bundle
was originated from repository.
Note: Whenever retrieve a resource bundle from repository, this method should be invoked.
Then this implementation should register it if not yet done or clear any outdated
cache associated with the basename
and locale
for a refreshed bundle.
registerPreviewBundle
in interface RepositoryResourceBundleMessageFormatProvider
basename
- resource bundle basenamelocale
- resource bundle localebundle
- resource bundlepublic MessageFormat getMessageFormat(ResourceBundle bundle, String code, Locale locale)
getMessageFormat
in interface RepositoryResourceBundleMessageFormatProvider
bundle
- the ResourceBundle to work oncode
- the message code to retrievelocale
- the Locale to use to build the MessageFormatnull
if no message
defined for the given codeprotected Map<ResourceBundle,Map<String,Map<Locale,MessageFormat>>> getCachedBundleMessageFormats()
protected Map<ResourceBundle,org.hippoecm.hst.util.KeyValue<String,Locale>> getBundleBasenameLocales()
protected Map<org.hippoecm.hst.util.KeyValue<String,Locale>,ResourceBundle> getBasenameLocaleBundles()
protected Map<ResourceBundle,Map<String,Map<Locale,MessageFormat>>> getCachedBundleMessageFormatsForPreview()
protected Map<ResourceBundle,org.hippoecm.hst.util.KeyValue<String,Locale>> getBundleBasenameLocalesForPreview()
protected Map<org.hippoecm.hst.util.KeyValue<String,Locale>,ResourceBundle> getBasenameLocaleBundlesForPreview()
Copyright © 2019. All rights reserved.