public abstract class AbstractMessages extends java.lang.Object implements Messages
Messages implementation common for all tiers.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BUNDLE_NAME |
protected java.lang.String |
confDir |
static java.lang.String |
EXT |
protected com.google.common.cache.Cache<java.lang.String,java.util.Properties> |
filePropertiesCache |
protected FormatStringsRegistry |
formatStringsRegistry |
protected GlobalConfig |
globalConfig |
protected java.lang.String |
mainMessagePack |
protected MessageTools |
messageTools |
protected java.util.Map<java.lang.String,java.lang.String> |
notFoundCache |
protected static java.util.Properties |
PROPERTIES_NOT_FOUND |
protected com.google.common.cache.Cache<java.lang.String,java.util.Properties> |
resourcePropertiesCache |
protected java.util.Map<java.lang.String,java.lang.String> |
strCache |
| Constructor and Description |
|---|
AbstractMessages() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cache(java.lang.String key,
java.lang.String msg) |
void |
clearCache() |
protected boolean |
enterPack(java.lang.String pack,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
java.lang.String |
findMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale)
Returns localized message or null if not found.
|
java.lang.String |
formatMainMessage(java.lang.String key,
java.lang.Object... params)
Get localized message from main message pack and use it as a format string for parameters provided.
Locale is determined by the current user session. |
java.lang.String |
formatMessage(java.lang.Class caller,
java.lang.String key,
java.util.Locale locale,
java.lang.Object... params)
Get localized message and use it as a format string for parameters provided
|
java.lang.String |
formatMessage(java.lang.Class caller,
java.lang.String key,
java.lang.Object... params)
Get localized message and use it as a format string for parameters provided.
Locale is determined by the current user session. |
java.lang.String |
formatMessage(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.lang.Object... params)
Get localized message and use it as a format string for parameters provided
|
java.lang.String |
formatMessage(java.lang.String pack,
java.lang.String key,
java.lang.Object... params)
Get localized message and use it as a format string for parameters provided.
Locale is determined by the current user session. |
int |
getCacheSize() |
protected java.lang.String |
getLocaleSuffix(java.util.Locale locale) |
java.lang.String |
getMainMessage(java.lang.String key)
Returns localized message using main message pack.
Locale is determined by the current user session. |
java.lang.String |
getMainMessage(java.lang.String key,
java.util.Locale locale)
Returns localized message
|
java.lang.String |
getMainMessagePack() |
java.lang.String |
getMessage(java.lang.Class caller,
java.lang.String key)
Returns localized message.
Locale is determined by the current user session. |
java.lang.String |
getMessage(java.lang.Class caller,
java.lang.String key,
java.util.Locale locale)
Returns localized message
|
java.lang.String |
getMessage(java.lang.Enum caller)
Returns localized message.
Locale is determined by the current user session. |
java.lang.String |
getMessage(java.lang.Enum caller,
java.util.Locale locale)
Returns localized message
|
java.lang.String |
getMessage(java.lang.String pack,
java.lang.String key)
Returns localized message.
Locale is determined by the current user session. |
java.lang.String |
getMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale)
Returns localized message
|
protected java.lang.String |
getMessageFromProperties(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Properties properties,
java.util.Set<java.lang.String> passedPacks) |
protected java.lang.String |
getPackName(java.lang.Class c) |
MessageTools |
getTools()
Convenient access to
MessageTools bean. |
protected abstract java.util.Locale |
getUserLocale() |
protected void |
init() |
protected java.lang.String |
internalGetMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale,
java.lang.String defaultValue,
boolean searchMainIfNotFound) |
protected java.util.Properties |
loadPropertiesFromFile(java.lang.String packPath,
java.util.Locale locale,
java.util.Locale truncatedLocale) |
protected java.util.Properties |
loadPropertiesFromResource(java.lang.String packPath,
java.util.Locale locale,
java.util.Locale truncatedLocale) |
protected java.lang.String |
makeCacheKey(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale) |
protected java.lang.String |
searchClasspath(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
protected java.lang.String |
searchFiles(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
protected java.lang.String |
searchIncludes(java.util.Properties properties,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
protected java.lang.String |
searchMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
protected java.lang.String |
searchOnePack(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks) |
protected abstract java.lang.String |
searchRemotely(java.lang.String pack,
java.lang.String key,
java.util.Locale locale) |
void |
setConfiguration(Configuration configuration) |
public static final java.lang.String BUNDLE_NAME
public static final java.lang.String EXT
@Inject protected MessageTools messageTools
@Inject protected FormatStringsRegistry formatStringsRegistry
protected GlobalConfig globalConfig
protected java.lang.String confDir
protected java.lang.String mainMessagePack
protected java.util.Map<java.lang.String,java.lang.String> strCache
protected java.util.Map<java.lang.String,java.lang.String> notFoundCache
protected com.google.common.cache.Cache<java.lang.String,java.util.Properties> filePropertiesCache
protected com.google.common.cache.Cache<java.lang.String,java.util.Properties> resourcePropertiesCache
protected static final java.util.Properties PROPERTIES_NOT_FOUND
protected abstract java.util.Locale getUserLocale()
@Nullable
protected abstract java.lang.String searchRemotely(java.lang.String pack,
java.lang.String key,
java.util.Locale locale)
@Inject public void setConfiguration(Configuration configuration)
@PostConstruct protected void init()
public MessageTools getTools()
MessagesMessageTools bean.public java.lang.String getMainMessagePack()
getMainMessagePack in interface Messagespublic java.lang.String getMessage(java.lang.Class caller,
java.lang.String key)
MessagesgetMessage in interface Messagescaller - class determining the message pack as full package namekey - message keypublic java.lang.String formatMessage(java.lang.Class caller,
java.lang.String key,
java.lang.Object... params)
MessagesformatMessage in interface Messagescaller - class determining the message pack as full package namekey - message keyparams - parameter valuespublic java.lang.String getMessage(java.lang.Class caller,
java.lang.String key,
java.util.Locale locale)
MessagesgetMessage in interface Messagescaller - class determining the message pack as full package namekey - message keylocale - message localepublic java.lang.String formatMessage(java.lang.Class caller,
java.lang.String key,
java.util.Locale locale,
java.lang.Object... params)
MessagesformatMessage in interface Messagescaller - class determining the message pack as full package namekey - message keylocale - message localeparams - parameter valuespublic java.lang.String getMessage(java.lang.Enum caller)
MessagesgetMessage in interface Messagescaller - enum determining the message pack and key:
public java.lang.String getMessage(java.lang.Enum caller,
java.util.Locale locale)
MessagesgetMessage in interface Messagescaller - enum determining the message pack and key:
locale - message localepublic java.lang.String getMessage(java.lang.String pack,
java.lang.String key)
MessagesgetMessage in interface Messagespack - package name to start searching the message. If the key is not found in this package,
it will be searched in parent package, and so forthkey - message keypublic java.lang.String getMainMessage(java.lang.String key)
MessagesgetMainMessage in interface Messageskey - message keypublic java.lang.String getMainMessage(java.lang.String key,
java.util.Locale locale)
MessagesgetMainMessage in interface Messageskey - message keylocale - message localepublic java.lang.String formatMessage(java.lang.String pack,
java.lang.String key,
java.lang.Object... params)
MessagesformatMessage in interface Messagespack - package name to start searching the message. If the key is not found in this package,
it will be searched in parent package, and so forthkey - message keyparams - parameter valuespublic java.lang.String formatMainMessage(java.lang.String key,
java.lang.Object... params)
MessagesformatMainMessage in interface Messageskey - message keyparams - parameter valuespublic java.lang.String getMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale)
MessagesgetMessage in interface Messagespacks - list of whitespace-separated package names. Searching of message is performed in reverse order -
starts from last name in the list. Each package is searched for the key, if the key is not found
in this package, it is searched in parent package, and so forthkey - message keylocale - message locale@Nullable
public java.lang.String findMessage(java.lang.String packs,
java.lang.String key,
@Nullable
java.util.Locale locale)
MessagesfindMessage in interface Messagespacks - list of whitespace-separated package names. Searching of message is performed in reverse order -
starts from last name in the list. Each package is searched for the key, if the key is not found
in this package, it is searched in parent package, and so forthkey - message keylocale - message locale. If null, current user locale is used.public java.lang.String formatMessage(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.lang.Object... params)
MessagesformatMessage in interface Messagespack - package name to start searching the message. If the key is not found in this package,
it will be searched in parent package, and so forthkey - message keylocale - message localeparams - parameter valuespublic int getCacheSize()
getCacheSize in interface Messagespublic void clearCache()
clearCache in interface Messagesprotected java.lang.String internalGetMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale,
java.lang.String defaultValue,
boolean searchMainIfNotFound)
@Nullable
protected java.lang.String searchMessage(java.lang.String packs,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
protected boolean enterPack(java.lang.String pack,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
protected java.lang.String searchOnePack(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
protected void cache(java.lang.String key,
java.lang.String msg)
protected java.lang.String searchFiles(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
protected java.lang.String searchClasspath(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
@Nullable
protected java.lang.String getMessageFromProperties(java.lang.String pack,
java.lang.String key,
java.util.Locale locale,
java.util.Locale truncatedLocale,
java.util.Properties properties,
java.util.Set<java.lang.String> passedPacks)
@Nullable
protected java.lang.String searchIncludes(java.util.Properties properties,
java.lang.String key,
java.util.Locale locale,
@Nullable
java.util.Locale truncatedLocale,
java.util.Set<java.lang.String> passedPacks)
protected java.util.Properties loadPropertiesFromFile(java.lang.String packPath,
java.util.Locale locale,
java.util.Locale truncatedLocale)
protected java.util.Properties loadPropertiesFromResource(java.lang.String packPath,
java.util.Locale locale,
java.util.Locale truncatedLocale)
protected java.lang.String getLocaleSuffix(java.util.Locale locale)
protected java.lang.String makeCacheKey(java.lang.String pack,
java.lang.String key,
@Nullable
java.util.Locale locale,
@Nullable
java.util.Locale truncatedLocale)
protected java.lang.String getPackName(java.lang.Class c)