Class DefaultCommerceRuleEngineCache

  • All Implemented Interfaces:
    RuleEngineCache, CommerceRuleEngineCache, org.springframework.beans.factory.InitializingBean

    public class DefaultCommerceRuleEngineCache
    extends DefaultRuleEngineCache
    implements CommerceRuleEngineCache, org.springframework.beans.factory.InitializingBean
    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 Detail

      • identityRAOProvider

        protected static final RAOProvider<java.lang.Object> 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 Detail

      • DefaultCommerceRuleEngineCache

        public DefaultCommerceRuleEngineCache()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • checkFactTemplates

        protected void checkFactTemplates​(java.util.Map<java.lang.Object,​java.util.Collection<java.lang.Object>> factTemplates)
        checks that for each given fact template class there is an RAOProvider registered.
        Parameters:
        factTemplates - the collection of fact templates to check
      • getFactTemplateCacheForKieBase

        protected java.util.Collection<java.lang.Object> getFactTemplateCacheForKieBase​(DroolsKIEBaseModel kieBase)
        returns the fact templates for the given kie base.
      • getFactTemplateCacheForKIEModule

        protected java.util.Optional<java.util.Map<java.lang.Object,​java.util.Collection<java.lang.Object>>> getFactTemplateCacheForKIEModule​(DroolsKIEModuleModel kieModule)
        returns the optional fact templates for the given kie module
      • getRaoProvider

        protected java.util.Optional<RAOProvider> getRaoProvider​(java.lang.Object factTemplate)
        returns the optional rao provider based on the given fact template's class
      • getRaoProviders

        protected java.util.Map<java.lang.Class,​RAOProvider> getRaoProviders()
      • setRaoProviders

        public void setRaoProviders​(java.util.Map<java.lang.Class,​RAOProvider> raoProviders)
      • getRaoCacheCreators

        protected java.util.List<RAOProvider> getRaoCacheCreators()
      • setRaoCacheCreators

        public void setRaoCacheCreators​(java.util.List<RAOProvider> raoCacheCreators)
      • setUseDeprecatedRRDsInCache

        @Deprecated(since="20.05",
                    forRemoval=true)
        public void setUseDeprecatedRRDsInCache​(boolean useDeprecatedRRDsInCache)
        Deprecated, for removal: This API element is subject to removal in a future version.
        flag is present only to enable deprecated RRD usage (backwards compatibility)
      • isUseDeprecatedRRDsInCache

        @Deprecated(since="20.05",
                    forRemoval=true)
        protected boolean isUseDeprecatedRRDsInCache()
        Deprecated, for removal: This API element is subject to removal in a future version.
        flag is present only to enable deprecated RRD usage (backwards compatibility)