public class MessageServiceImpl extends Object implements MessageService
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTIES_FILE_SUFFIX |
Constructor and Description |
---|
MessageServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
String |
getBaseBundleName(String resourceName) |
Locale |
getContentLocale()
Get the content local for the current thread.
This will revert to MessageService.getLocale() if no value has been defined. |
Locale |
getLocale()
Get the general local for the current thread, will revert to the default locale if none
specified for this thread.
|
String |
getMessage(String messageKey) |
String |
getMessage(String messageKey,
Locale locale) |
String |
getMessage(String messageKey,
Locale locale,
Object... params) |
String |
getMessage(String messageKey,
Object... params) |
Locale |
getNearestLocale(Locale templateLocale,
Set<Locale> options)
Searches for the nearest locale from the available options.
|
protected org.alfresco.service.cmr.repository.NodeRef |
getNode(org.alfresco.service.cmr.repository.NodeRef rootNodeRef,
String path) |
Set<String> |
getRegisteredBundles()
Get set of registered message resource bundles
|
ResourceBundle |
getRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef,
String path,
Locale locale)
Get message resource bundle from the repository
note: also used by Web Client (ResourceBundleWrapper)
|
void |
init() |
void |
onDisableTenant() |
void |
onEnableTenant() |
Locale |
parseLocale(String localeStr)
Factory method to create a Locale from a lang_country_variant string.
|
void |
register(MessageDeployer messageDeployer)
Register message deployer with message service
|
void |
registerResourceBundle(String resBundlePath)
Register a resource bundle.
|
void |
reset()
Resets the message service
|
protected org.alfresco.service.cmr.repository.NodeRef |
resolveQNamePath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef,
String[] pathPrefixQNameStrings) |
void |
setContentLocale(Locale locale)
Set the content locale for the current thread.
|
void |
setContentService(ContentService contentService) |
void |
setLoadedResourceBundlesCache(org.alfresco.repo.cache.SimpleCache<String,Map<Locale,Set<String>>> loadedResourceBundlesCache) |
void |
setLocale(Locale locale)
Set the locale for the current thread.
|
void |
setMessagesCache(org.alfresco.repo.cache.SimpleCache<String,Map<Locale,Map<String,String>>> messagesCache) |
void |
setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService) |
void |
setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) |
void |
setResourceBundleBaseNamesCache(org.alfresco.repo.cache.SimpleCache<String,Set<String>> resourceBundleBaseNamesCache) |
void |
setTenantService(org.alfresco.repo.tenant.TenantService tenantService) |
void |
setTryLockTimeout(long tryLockTimeout) |
void |
unregisterResourceBundle(String resBundlePath)
Unregister a resource bundle
|
public static final String PROPERTIES_FILE_SUFFIX
public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
public void setContentService(ContentService contentService)
public void setResourceBundleBaseNamesCache(org.alfresco.repo.cache.SimpleCache<String,Set<String>> resourceBundleBaseNamesCache)
public void setLoadedResourceBundlesCache(org.alfresco.repo.cache.SimpleCache<String,Map<Locale,Set<String>>> loadedResourceBundlesCache)
public void setMessagesCache(org.alfresco.repo.cache.SimpleCache<String,Map<Locale,Map<String,String>>> messagesCache)
public void setTryLockTimeout(long tryLockTimeout)
public void setLocale(Locale locale)
MessageService
setLocale
in interface MessageService
locale
- the localepublic Locale getLocale()
MessageService
getLocale
in interface MessageService
public void setContentLocale(Locale locale)
MessageService
setContentLocale
in interface MessageService
locale
- the content localepublic Locale getContentLocale()
MessageService
MessageService.getLocale()
if no value has been defined.getContentLocale
in interface MessageService
public Locale getNearestLocale(Locale templateLocale, Set<Locale> options)
MessageService
getNearestLocale
in interface MessageService
templateLocale
- the template to search for or null to match any localeoptions
- the available locales to search frompublic Locale parseLocale(String localeStr)
MessageService
parseLocale
in interface MessageService
localeStr
- e.g. fr_FRdefault
if the
string is invalidpublic void registerResourceBundle(String resBundlePath)
MessageService
This should be the bundle base path eg, alfresco/messages/errors or, workspace://SpaceStore/app:company_home/app:dictionary/app:labels/cm:errors
Once registered the messages will be available via getMessage, assuming the bundle resource exists at the given path location.
registerResourceBundle
in interface MessageService
resBundlePath
- the bundle base pathpublic String getMessage(String messageKey)
getMessage
in interface org.alfresco.service.cmr.i18n.MessageLookup
public String getMessage(String messageKey, Locale locale)
getMessage
in interface org.alfresco.service.cmr.i18n.MessageLookup
public String getMessage(String messageKey, Object... params)
getMessage
in interface org.alfresco.service.cmr.i18n.MessageLookup
public String getMessage(String messageKey, Locale locale, Object... params)
getMessage
in interface org.alfresco.service.cmr.i18n.MessageLookup
public void unregisterResourceBundle(String resBundlePath)
MessageService
This should be the bundle base path eg alfresco/messages/errors or workspace://SpaceStore/app:company_home/app:dictionary/app:labels/cm:errors
Once unregistered the messages will no longer be available via getMessage
unregisterResourceBundle
in interface MessageService
resBundlePath
- the bundle base pathpublic ResourceBundle getRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef, String path, Locale locale) throws IOException
MessageService
getRepoResourceBundle
in interface MessageService
storeRef
- store refpath
- repository path (XPath)locale
- localeIOException
public void onEnableTenant()
onEnableTenant
in interface org.alfresco.repo.tenant.TenantDeployer
public void onDisableTenant()
onDisableTenant
in interface org.alfresco.repo.tenant.TenantDeployer
public void init()
init
in interface org.alfresco.repo.tenant.TenantDeployer
public void destroy()
destroy
in interface org.alfresco.repo.tenant.TenantDeployer
public Set<String> getRegisteredBundles()
MessageService
getRegisteredBundles
in interface MessageService
public void register(MessageDeployer messageDeployer)
MessageService
register
in interface MessageService
messageDeployer
- MessageDeployerpublic void reset()
public String getBaseBundleName(String resourceName)
getBaseBundleName
in interface MessageService
protected org.alfresco.service.cmr.repository.NodeRef getNode(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, String path)
protected org.alfresco.service.cmr.repository.NodeRef resolveQNamePath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, String[] pathPrefixQNameStrings)
Copyright © 2005–2017 Alfresco Software. All rights reserved.