|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.i18n.MessageServiceImpl
public class MessageServiceImpl
Message Service to get localised messages/strings which have been loaded from resource bundles either dynamically deployed in the Repository and/or statically loaded from the Classpath. Also provides methods (delegated to core utility class) to access the Locale of the current thread.
Field Summary | |
---|---|
static java.lang.String |
PROPERTIES_FILE_SUFFIX
|
Constructor Summary | |
---|---|
MessageServiceImpl()
|
Method Summary | |
---|---|
void |
destroy()
|
java.lang.String |
getBaseBundleName(java.lang.String resourceName)
|
java.util.Locale |
getContentLocale()
Get the content local for the current thread. This will revert to MessageService.getLocale() if no value has been defined. |
java.util.Locale |
getLocale()
Get the general local for the current thread, will revert to the default locale if none specified for this thread. |
java.lang.String |
getMessage(java.lang.String messageKey)
Get message from registered resource bundle. |
java.lang.String |
getMessage(java.lang.String messageKey,
java.util.Locale locale)
Get a localised message string |
java.lang.String |
getMessage(java.lang.String messageKey,
java.util.Locale locale,
java.lang.Object[] params)
Get a localised message string, parameterized using standard MessageFormatter. |
java.lang.String |
getMessage(java.lang.String messageKey,
java.lang.Object[] params)
Get a localised message string, parameterized using standard MessageFormatter. |
java.util.Locale |
getNearestLocale(java.util.Locale templateLocale,
java.util.Set 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,
java.lang.String path)
|
java.util.Set |
getRegisteredBundles()
Get set of registered message resource bundles |
java.util.ResourceBundle |
getRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef,
java.lang.String path,
java.util.Locale locale)
Get message resource bundle from the repository note: also used by Web Client (ResourceBundleWrapper) |
void |
init()
|
void |
onDisableTenant()
|
void |
onEnableTenant()
|
java.util.Locale |
parseLocale(java.lang.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(java.lang.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,
java.lang.String[] pathPrefixQNameStrings)
|
void |
setContentLocale(java.util.Locale locale)
Set the content locale for the current thread. |
void |
setContentService(ContentService contentService)
|
void |
setLoadedResourceBundlesCache(org.alfresco.repo.cache.SimpleCache loadedResourceBundlesCache)
|
void |
setLocale(java.util.Locale locale)
Set the locale for the current thread. |
void |
setMessagesCache(org.alfresco.repo.cache.SimpleCache 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 resourceBundleBaseNamesCache)
|
void |
setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
|
void |
unregisterResourceBundle(java.lang.String resBundlePath)
Unregister a resource bundle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTIES_FILE_SUFFIX
Constructor Detail |
---|
public MessageServiceImpl()
Method Detail |
---|
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 resourceBundleBaseNamesCache)
public void setLoadedResourceBundlesCache(org.alfresco.repo.cache.SimpleCache loadedResourceBundlesCache)
public void setMessagesCache(org.alfresco.repo.cache.SimpleCache messagesCache)
public void setLocale(java.util.Locale locale)
MessageService
setLocale
in interface MessageService
locale
- the localepublic java.util.Locale getLocale()
MessageService
getLocale
in interface MessageService
public void setContentLocale(java.util.Locale locale)
MessageService
setContentLocale
in interface MessageService
locale
- the content localepublic java.util.Locale getContentLocale()
MessageService
MessageService.getLocale()
if no value has been defined.
getContentLocale
in interface MessageService
public java.util.Locale getNearestLocale(java.util.Locale templateLocale, java.util.Set options)
MessageService
getNearestLocale
in interface MessageService
templateLocale
- the template to search for or null to match any localeoptions
- the available locales to search from
public java.util.Locale parseLocale(java.lang.String localeStr)
MessageService
parseLocale
in interface MessageService
localeStr
- e.g. fr_FR
default
if the
string is invalidpublic void registerResourceBundle(java.lang.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
public java.lang.String getMessage(java.lang.String messageKey)
MessageService
getMessage
in interface MessageService
messageKey
- message key
public java.lang.String getMessage(java.lang.String messageKey, java.util.Locale locale)
MessageService
getMessage
in interface MessageService
messageKey
- the message keylocale
- override the current locale
public java.lang.String getMessage(java.lang.String messageKey, java.lang.Object[] params)
MessageService
getMessage
in interface MessageService
messageKey
- message keyparams
- format parameters
public java.lang.String getMessage(java.lang.String messageKey, java.util.Locale locale, java.lang.Object[] params)
MessageService
getMessage
in interface MessageService
messageKey
- the message keylocale
- override current localeparams
- the localised message string
public void unregisterResourceBundle(java.lang.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
public java.util.ResourceBundle getRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String path, java.util.Locale locale) throws java.io.IOException
MessageService
getRepoResourceBundle
in interface MessageService
storeRef
- store refpath
- repository path (XPath)locale
- locale
java.io.IOException
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 java.util.Set getRegisteredBundles()
MessageService
getRegisteredBundles
in interface MessageService
public void register(MessageDeployer messageDeployer)
MessageService
register
in interface MessageService
public void reset()
public java.lang.String getBaseBundleName(java.lang.String resourceName)
getBaseBundleName
in interface MessageService
protected org.alfresco.service.cmr.repository.NodeRef getNode(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path)
protected org.alfresco.service.cmr.repository.NodeRef resolveQNamePath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String[] pathPrefixQNameStrings)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |