Class SparseInternationalMessageOverrideStrategy
java.lang.Object
com.broadleafcommerce.i18n.enterprise.config.service.SparseInternationalMessageOverrideStrategy
- All Implemented Interfaces:
InternationalMessageOverrideStrategy,org.broadleafcommerce.common.cache.OverridePreCacheInitializer,org.springframework.core.Ordered
@Component("blSparseInternationalMessageOverrideStrategy")
public class SparseInternationalMessageOverrideStrategy
extends Object
implements InternationalMessageOverrideStrategy, org.broadleafcommerce.common.cache.OverridePreCacheInitializer
A retrieval and caching strategy for international messages. Primarily supports multitenant scenarios with the following characteristics:
- A very large template message catalog
- A small number of standard site overrides
- Small or large quantity of individual standard sites
ThresholdCacheInternationalMessageOverrideStrategy,
this strategy opts for completely caching overrides and minimizing template queries.
Hybrid configurations are also possible for small to medium size template message catalogs where the threshold
count bounding queries are not a concern and complete (or partial) caching of the template catalog can be achieved. However,
such a strategy may provide little to no benefit over the out-of-the-box ThresholdCacheInternationalMessageOverrideStrategy.
See the templateEnabled property for more information.
This strategy also works best when there are few standard sites with isolated values (i.e. the value was created in the standard
site and was not inherited from a profile or catalog). This is because the strategy can utilize an optimized template
query that is portable across sites if it doesn't have to take into account the standard site. The strategy uses
OverridePreCacheService.isActiveIsolatedSiteForType(Long, String) to figure out this state.
This strategy is disabled by default. Please see the javadoc for com.broadleafcommerce.tenant.service.cache.SparseOverridePreCacheServiceImpl (MultiTenant only)
for more information on how to enable this strategy via configuration of that service.- Author:
- Jeff Fischer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InternationalMessageDaoprotected jakarta.persistence.EntityManagerprotected org.broadleafcommerce.common.extension.TemplateOnlyQueryExtensionManagerstatic final intprotected org.broadleafcommerce.common.cache.OverridePreCacheServiceprotected booleanWhether or notgetLocaleBasedTemplateValue(String, String, String, String, String, String)will be utilized from this strategy.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetCacheKey(InternationalMessage message) protected StringgetCacheKey(String propertyName, String localeCode) org.broadleafcommerce.common.i18n.service.LocalePairgetLocaleBasedOverride(String propertyName, Locale locale, String basicCacheKey) Retrieve the standard site override message, if applicableorg.broadleafcommerce.common.i18n.service.LocalePairgetLocaleBasedTemplateValue(String templateCacheKey, String propertyName, String localeCode, String localeCountryCode, String specificPropertyKey, String generalPropertyKey) Retrieve the template level message, if applicableintgetOrder()protected List<InternationalMessage>getTemplateMessages(String propertyName, String localeCode) org.broadleafcommerce.common.extension.StandardCacheIteminitializeOverride(Object entity) booleanisOverrideQualified(Class<?> type) booleanvalidateTemplateProcessing(String standardCacheKey, String templateCacheKey) Whether or not a template version should be searched for.
-
Field Details
-
PRECACHED_SPARSE_OVERRIDE_ORDER
public static final int PRECACHED_SPARSE_OVERRIDE_ORDER- See Also:
-
preCachedSparseOverrideService
protected org.broadleafcommerce.common.cache.OverridePreCacheService preCachedSparseOverrideService -
extensionManager
protected org.broadleafcommerce.common.extension.TemplateOnlyQueryExtensionManager extensionManager -
em
protected jakarta.persistence.EntityManager em -
dao
-
templateEnabled
@Value("${precached.sparse.override.internationalmessage.template.enabled:true}") protected boolean templateEnabledWhether or notgetLocaleBasedTemplateValue(String, String, String, String, String, String)will be utilized from this strategy. If false, the fallbackThresholdCacheInternationalMessageOverrideStrategy.getLocaleBasedTemplateValue(String, String, String, String, String, String)will be used instead. If the 'template' repository (MT concept) is large, this value should be left true. However, if the 'template' repository is relatively small, you may want to consider setting this to false in order to leverage the possibility of complete caching in the default strategy. SeeInternationalMessageSupport.getThresholdForFullCache()for more info on this option. The default value is true. Set the 'precached.sparse.override.internationalmessage.template.enabled' property to change the value. This value is meaningless if the current standard site is found to contain active isolated values for international messages. Review the documentation in com.broadleafcommerce.tenant.service.cache.SparseOverridePreCacheServiceImpl for more information.
-
-
Constructor Details
-
SparseInternationalMessageOverrideStrategy
public SparseInternationalMessageOverrideStrategy()
-
-
Method Details
-
getLocaleBasedOverride
public org.broadleafcommerce.common.i18n.service.LocalePair getLocaleBasedOverride(String propertyName, Locale locale, String basicCacheKey) Description copied from interface:InternationalMessageOverrideStrategyRetrieve the standard site override message, if applicable- Specified by:
getLocaleBasedOverridein interfaceInternationalMessageOverrideStrategy- Returns:
-
getLocaleBasedTemplateValue
public org.broadleafcommerce.common.i18n.service.LocalePair getLocaleBasedTemplateValue(String templateCacheKey, String propertyName, String localeCode, String localeCountryCode, String specificPropertyKey, String generalPropertyKey) Description copied from interface:InternationalMessageOverrideStrategyRetrieve the template level message, if applicable- Specified by:
getLocaleBasedTemplateValuein interfaceInternationalMessageOverrideStrategy- Returns:
-
isOverrideQualified
- Specified by:
isOverrideQualifiedin interfaceorg.broadleafcommerce.common.cache.OverridePreCacheInitializer
-
initializeOverride
- Specified by:
initializeOverridein interfaceorg.broadleafcommerce.common.cache.OverridePreCacheInitializer
-
validateTemplateProcessing
Description copied from interface:InternationalMessageOverrideStrategyWhether or not a template version should be searched for. If false, then the system will return null for the message, should an override not be found.- Specified by:
validateTemplateProcessingin interfaceInternationalMessageOverrideStrategy- Returns:
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
getTemplateMessages
-
getCacheKey
-
getCacheKey
-