Class InternationalMessageServiceImpl
java.lang.Object
com.broadleafcommerce.i18n.enterprise.config.service.InternationalMessageServiceImpl
- All Implemented Interfaces:
InternationalMessageService,InternationalMessageSupport
@Service("blInternationalMessageService")
public class InternationalMessageServiceImpl
extends Object
implements InternationalMessageService, InternationalMessageSupport
Service that retrieves International Messages from the database.
- Author:
- Elbert Bautista (elbertbautista), Jeff Fischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.broadleafcommerce.common.extensibility.cache.JCacheUtilprotected org.broadleafcommerce.common.entity.service.EntityInformationServiceprotected javax.cache.Cacheprotected InternationalMessageDaoprotected List<InternationalMessageOverrideStrategy>protected intprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindBestStandardMessage(String specificPropertyKey, String generalPropertyKey, Map<String, org.broadleafcommerce.common.extension.StandardCacheItem> propertyTranslationMap) Find the most appropriate message in the map.findBestTemplateMessage(String specificPropertyKey, String generalPropertyKey, Map<String, InternationalMessage> propertyTranslationMap) Find the most appropriate message in the map.getCacheKey(String propertyName, org.broadleafcommerce.common.extension.ResultType resultType) Build a cache keygetCacheKeyListForTemplateSite(String propertyName) Returns a list of cacheKeys for a template sitejavax.cache.CacheRetrieve the backing cacheprotected StringgetOverrideMessage(String propertyName, Locale locale) protected StringgetTemplateMessage(String standardCacheKey, String propertyName, String localeCode, String localeCountryCode, String specificPropertyKey, String generalPropertyKey) intRetrieve the threshold under which the full list of template catalog messages are cached.intRetrieve the threshold under which the full list of standard site message overrides are cached.org.broadleafcommerce.common.extension.StandardCacheItemlookupMessageFromMap(String key, Map<String, org.broadleafcommerce.common.extension.StandardCacheItem> propertyTranslationMap) Look up a cached message from the map based on a keyvoidremoveFromCache(InternationalMessage internationalMessage, String profileId) protected StringreplaceEmptyWithNullResponse(String response) resolveInternationalMessage(String name, Locale locale) This method adds some complexity to the seemingly simple task of looking up a message based on locale.voidsetTemplateThresholdForFullCache(int templateThresholdForFullCache) voidsetThresholdForFullCache(int thresholdForFullCache)
-
Field Details
-
internationalMessageCache
protected javax.cache.Cache internationalMessageCache -
internationalMessageDao
-
entityInformationService
protected org.broadleafcommerce.common.entity.service.EntityInformationService entityInformationService -
extensionManager
-
thresholdForFullCache
@Value("${i18nMessages.thresholdForFullCache:1000}") protected int thresholdForFullCache -
templateThresholdForFullCache
@Value("${i18nMessages.thresholdForFullCache:1000}") protected int templateThresholdForFullCache -
cacheUtil
@Autowired protected org.broadleafcommerce.common.extensibility.cache.JCacheUtil cacheUtil -
strategies
-
-
Constructor Details
-
InternationalMessageServiceImpl
public InternationalMessageServiceImpl()
-
-
Method Details
-
resolveInternationalMessage
This method adds some complexity to the seemingly simple task of looking up a message based on locale.We want to minimize queries based on locale as well as recognize that in a multi-site installation, messages are likely to be shared from top level down to the sites. For example, consider that an installation has 1,000 sites. All of these sites probably calls the "Login" button "Login" in english. We'd prefer to get efficient cache hits in a scenario like this.
- Specified by:
resolveInternationalMessagein interfaceInternationalMessageService- Returns:
- - a DB InternationalMessage or null if not found.
-
findById
- Specified by:
findByIdin interfaceInternationalMessageService
-
removeFromCache
- Specified by:
removeFromCachein interfaceInternationalMessageService
-
getOverrideMessage
-
getTemplateMessage
-
findBestStandardMessage
public InternationalMessage findBestStandardMessage(String specificPropertyKey, String generalPropertyKey, Map<String, org.broadleafcommerce.common.extension.StandardCacheItem> propertyTranslationMap) Description copied from interface:InternationalMessageSupportFind the most appropriate message in the map. The most specific qualified message will win.- Specified by:
findBestStandardMessagein interfaceInternationalMessageSupport- Returns:
-
findBestTemplateMessage
public InternationalMessage findBestTemplateMessage(String specificPropertyKey, String generalPropertyKey, Map<String, InternationalMessage> propertyTranslationMap) Description copied from interface:InternationalMessageSupportFind the most appropriate message in the map. The most specific qualified message will win.- Specified by:
findBestTemplateMessagein interfaceInternationalMessageSupport- Returns:
-
getCacheKey
public String getCacheKey(String propertyName, org.broadleafcommerce.common.extension.ResultType resultType) Description copied from interface:InternationalMessageSupportBuild a cache key- Specified by:
getCacheKeyin interfaceInternationalMessageSupport- Returns:
-
getCacheKeyListForTemplateSite
Description copied from interface:InternationalMessageSupportReturns a list of cacheKeys for a template site- Specified by:
getCacheKeyListForTemplateSitein interfaceInternationalMessageSupport- Returns:
-
getInternationalMessageCache
public javax.cache.Cache getInternationalMessageCache()Description copied from interface:InternationalMessageSupportRetrieve the backing cache- Specified by:
getInternationalMessageCachein interfaceInternationalMessageSupport- Returns:
-
getThresholdForFullCache
public int getThresholdForFullCache()Description copied from interface:InternationalMessageSupportRetrieve the threshold under which the full list of standard site message overrides are cached. SeethresholdForFullCachefor more information on setting the value.- Specified by:
getThresholdForFullCachein interfaceInternationalMessageSupport- Returns:
-
setThresholdForFullCache
public void setThresholdForFullCache(int thresholdForFullCache) - Specified by:
setThresholdForFullCachein interfaceInternationalMessageSupport
-
getTemplateThresholdForFullCache
public int getTemplateThresholdForFullCache()Description copied from interface:InternationalMessageSupportRetrieve the threshold under which the full list of template catalog messages are cached. SeetemplateThresholdForFullCachefor more information on setting the value.- Specified by:
getTemplateThresholdForFullCachein interfaceInternationalMessageSupport- Returns:
-
setTemplateThresholdForFullCache
public void setTemplateThresholdForFullCache(int templateThresholdForFullCache) - Specified by:
setTemplateThresholdForFullCachein interfaceInternationalMessageSupport
-
lookupMessageFromMap
public org.broadleafcommerce.common.extension.StandardCacheItem lookupMessageFromMap(String key, Map<String, org.broadleafcommerce.common.extension.StandardCacheItem> propertyTranslationMap) Description copied from interface:InternationalMessageSupportLook up a cached message from the map based on a key- Specified by:
lookupMessageFromMapin interfaceInternationalMessageSupport- Returns:
-
replaceEmptyWithNullResponse
-