Class DefaultCommerceRuleEngineCache
java.lang.Object
de.hybris.platform.ruleengine.cache.impl.DefaultRuleEngineCache
de.hybris.platform.ruleengineservices.cache.impl.DefaultCommerceRuleEngineCache
- All Implemented Interfaces:
RuleEngineCache,CommerceRuleEngineCache
public class DefaultCommerceRuleEngineCache
extends DefaultRuleEngineCache
implements CommerceRuleEngineCache
DefaultCommerceRuleEngineCache is the default implementation for caching fact templates. The
getRaoCacheCreators() are used by this cache's cache builders
(createKIEModuleCacheBuilder(DroolsKIEModuleModel)) to create "facts templates" during the initialization of
a module. The getRaoProviders() are used to generate copies of the cached "fact templates" (see
getCachedFacts(DroolsKIEBaseModel)).
Note: During the addKIEModuleCache(KIEModuleCacheBuilder) a check (see checkFactTemplates(Map)) is
done to ensure that for each created fact template there is a registered RAOProvider (matched by its class)
that can create a copy of the fact template. This check can be disabled (via setting the
defaultCommerceRuleEngineCache.checkRAOProvidersForCache property to false). If the check is disabled and a
fact template has no corresponding RAOProvider to create a copy, it will simply be inserted directly as a fact into
the rule evaluation context. This can be useful if a fact template doesn't require to have a copy created for each
rule evaluation (e.g. if the fact template is not modified by any rules during rule evaluation).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final RAOProvider<Object>the identity rao provider returns a singleton set of the given fact template.Fields inherited from class de.hybris.platform.ruleengine.cache.impl.DefaultRuleEngineCache
kieBaseCacheKeyGenerator, kieModuleCacheKeyGenerator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKIEModuleCache(KIEModuleCacheBuilder cacheBuilder) adds the given cache builder to the global globals cache.protected voidcheckFactTemplates(Map<Object, Collection<Object>> factTemplates) checks that for each given fact template class there is an RAOProvider registered.createKIEModuleCacheBuilder(DroolsKIEModuleModel kieModule) creates a RuleEngineKIEModuleCacheBuilder object for the given kieModule.getCachedFacts(DroolsKIEBaseModel kieBase) returns the facts registered for the given kieBase.protected Collection<Object>returns the fact templates for the given kie base.protected Optional<Map<Object,Collection<Object>>> returns the optional fact templates for the given kie moduleprotected List<RAOProvider>protected Optional<RAOProvider>getRaoProvider(Object factTemplate) returns the optional rao provider based on the given fact template's classprotected Map<Class,RAOProvider> voidsetRaoCacheCreators(List<RAOProvider> raoCacheCreators) voidsetRaoProviders(Map<Class, RAOProvider> raoProviders) Methods inherited from class de.hybris.platform.ruleengine.cache.impl.DefaultRuleEngineCache
getConfigurationService, getGlobalsCacheForKIEModule, getGlobalsForKIEBase, getKieBaseCacheKeyGenerator, getKieModuleCacheKeyGenerator, getRuleGlobalsBeanProvider, setConfigurationService, setKieBaseCacheKeyGenerator, setKieModuleCacheKeyGenerator, setRuleGlobalsBeanProviderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.ruleengine.cache.RuleEngineCache
getGlobalsForKIEBase
-
Field Details
-
identityRAOProvider
the identity rao provider returns a singleton set of the given fact template. This is used as a default rao provider if none is registered for the class of the given fact template.
-
-
Constructor Details
-
DefaultCommerceRuleEngineCache
public DefaultCommerceRuleEngineCache()
-
-
Method Details
-
createKIEModuleCacheBuilder
Description copied from interface:RuleEngineCachecreates a RuleEngineKIEModuleCacheBuilder object for the given kieModule.- Specified by:
createKIEModuleCacheBuilderin interfaceRuleEngineCache- Overrides:
createKIEModuleCacheBuilderin classDefaultRuleEngineCache- Returns:
- a newly instantiated cache builder for the given kieModule
-
addKIEModuleCache
Description copied from interface:RuleEngineCacheadds the given cache builder to the global globals cache.- Specified by:
addKIEModuleCachein interfaceRuleEngineCache- Overrides:
addKIEModuleCachein classDefaultRuleEngineCache- Parameters:
cacheBuilder- the cache builder for which to add the cache
-
getCachedFacts
Description copied from interface:CommerceRuleEngineCachereturns the facts registered for the given kieBase.- Specified by:
getCachedFactsin interfaceCommerceRuleEngineCache- Returns:
- a collection of facts derived from the cached fact templates
-
checkFactTemplates
checks that for each given fact template class there is an RAOProvider registered.- Parameters:
factTemplates- the collection of fact templates to check
-
getFactTemplateCacheForKieBase
returns the fact templates for the given kie base. -
getFactTemplateCacheForKIEModule
protected Optional<Map<Object,Collection<Object>>> getFactTemplateCacheForKIEModule(DroolsKIEModuleModel kieModule) returns the optional fact templates for the given kie module -
getRaoProvider
returns the optional rao provider based on the given fact template's class -
getRaoProviders
-
setRaoProviders
-
getRaoCacheCreators
-
setRaoCacheCreators
-