@Component(value="blSparseTranslationOverrideStrategy") public class SparseTranslationOverrideStrategy extends Object implements TranslationOverrideStrategy, OverridePreCacheInitializer
ThresholdCacheTranslationOverrideStrategy,
this strategy opts for completely caching overrides and minimizing template queries. The highest template query optimization
is achieved in conjunction with the 'precached.sparse.override.template.search.restrict.catalog' property set to true (false by
default). See com.broadleafcommerce.tenant.service.extension.MultiTenantTemplateOnlyQueryExtensionHandler for more information,
since this setting assumes the translated entity is in the same catalog as the Translation instance, which may
not be true for all installations.
Hybrid configurations are also possible for small to medium size template translation 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 ThresholdCacheTranslationOverrideStrategy.
See the templateEnabled property for more information.
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.ThresholdCacheTranslationOverrideStrategy| Modifier and Type | Field and Description |
|---|---|
protected javax.persistence.EntityManager |
em |
protected TemplateOnlyQueryExtensionManager |
extensionManager |
static int |
PRECACHED_SPARSE_OVERRIDE_ORDER |
protected OverridePreCacheService |
preCachedSparseOverrideService |
protected boolean |
templateEnabled
Whether or not
getLocaleBasedTemplateValue(String, String, TranslatedEntity, String, String, String, String, String)
will be utilized from this strategy. |
| Constructor and Description |
|---|
SparseTranslationOverrideStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getCacheKey(TranslatedEntity type,
String entityId,
String fieldName,
String localeCode) |
protected String |
getCacheKey(Translation translation) |
LocalePair |
getLocaleBasedOverride(String property,
TranslatedEntity entityType,
String entityId,
String localeCode,
String localeCountryCode,
String basicCacheKey)
Retrieve the standard site override translation, if applicable
|
LocalePair |
getLocaleBasedTemplateValue(String templateCacheKey,
String property,
TranslatedEntity entityType,
String entityId,
String localeCode,
String localeCountryCode,
String specificPropertyKey,
String generalPropertyKey)
Retrieve the template level translation, if applicable
|
int |
getOrder() |
protected List<Translation> |
getTemplateTranslations(TranslatedEntity entityType,
String entityId,
String property,
String localeCode) |
StandardCacheItem |
initializeOverride(Object entity)
Perform any initialization tasks (e.g.
|
boolean |
isOverrideQualified(Class<?> type)
Whether or not this initializer is qualified to work on the given entity type
|
boolean |
isTemplateEnabled() |
void |
setTemplateEnabled(boolean templateEnabled) |
boolean |
validateTemplateProcessing(String standardCacheKey,
String templateCacheKey)
Whether or not a template version should be searched for.
|
public static final int PRECACHED_SPARSE_OVERRIDE_ORDER
protected OverridePreCacheService preCachedSparseOverrideService
protected TemplateOnlyQueryExtensionManager extensionManager
protected javax.persistence.EntityManager em
@Value(value="${precached.sparse.override.translation.template.enabled:true}")
protected boolean templateEnabled
getLocaleBasedTemplateValue(String, String, TranslatedEntity, String, String, String, String, String)
will be utilized from this strategy. If false, the fallback
ThresholdCacheTranslationOverrideStrategy.getLocaleBasedTemplateValue(String, String, TranslatedEntity, 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. See TranslationSupport.getThresholdForFullCache() for more info on this
option.
The default value is true. Set the 'precached.sparse.override.translation.template.enabled' property to change the value.public LocalePair getLocaleBasedOverride(String property, TranslatedEntity entityType, String entityId, String localeCode, String localeCountryCode, String basicCacheKey)
TranslationOverrideStrategygetLocaleBasedOverride in interface TranslationOverrideStrategypublic LocalePair getLocaleBasedTemplateValue(String templateCacheKey, String property, TranslatedEntity entityType, String entityId, String localeCode, String localeCountryCode, String specificPropertyKey, String generalPropertyKey)
TranslationOverrideStrategygetLocaleBasedTemplateValue in interface TranslationOverrideStrategypublic boolean isOverrideQualified(Class<?> type)
OverridePreCacheInitializerisOverrideQualified in interface OverridePreCacheInitializerpublic StandardCacheItem initializeOverride(Object entity)
OverridePreCacheInitializerinitializeOverride in interface OverridePreCacheInitializerpublic boolean validateTemplateProcessing(String standardCacheKey, String templateCacheKey)
TranslationOverrideStrategyvalidateTemplateProcessing in interface TranslationOverrideStrategypublic int getOrder()
getOrder in interface org.springframework.core.Orderedpublic boolean isTemplateEnabled()
public void setTemplateEnabled(boolean templateEnabled)
protected List<Translation> getTemplateTranslations(TranslatedEntity entityType, String entityId, String property, String localeCode)
protected String getCacheKey(Translation translation)
protected String getCacheKey(TranslatedEntity type, String entityId, String fieldName, String localeCode)
Copyright © 2017. All rights reserved.