Class DefaultCommerceRuleEngineService

  • All Implemented Interfaces:
    RuleEngineService

    public class DefaultCommerceRuleEngineService
    extends java.lang.Object
    implements RuleEngineService
    Default implementation of Commerce Rule Engine Service.
    • Constructor Detail

      • DefaultCommerceRuleEngineService

        public DefaultCommerceRuleEngineService()
    • Method Detail

      • initialize

        public void initialize​(AbstractRulesModuleModel module,
                               java.lang.String deployedMvnVersion,
                               boolean propagateToOtherNodes,
                               boolean enableIncrementalUpdate,
                               RuleEngineActionResult result)
        Description copied from interface: RuleEngineService
        Since 6.4 Initializes the given rules module (and if propagateToOtherNodes is set to true propagates a RuleEngineInitializedEvent to other nodes).
        Specified by:
        initialize in interface RuleEngineService
        Parameters:
        module - the module to be initialized
        deployedMvnVersion - currently deployed mvn version of the rule engine module
        propagateToOtherNodes - if true propagates a RuleEngineInitializedEvent to other nodes.
        enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
        result - the instance of RuleEngineActionResult accumulating the results of initialization
      • initializeNonBlocking

        public void initializeNonBlocking​(AbstractRulesModuleModel module,
                                          java.lang.String deployedReleaseIdVersion,
                                          boolean propagateToOtherNodes,
                                          boolean enableIncrementalUpdate,
                                          RuleEngineActionResult result)
        Description copied from interface: RuleEngineService
        Since 6.4 Asynchronously initializes the given rules module (and if propagateToOtherNodes is set to true propagates a RuleEngineInitializedEvent to other nodes).
        Specified by:
        initializeNonBlocking in interface RuleEngineService
        Parameters:
        module - the module to be initialized
        deployedReleaseIdVersion - currently deployed version of the Kie Module
        propagateToOtherNodes - if true propagates a RuleEngineInitializedEvent to other nodes.
        enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
        result - the instance of RuleEngineActionResult accumulating the results of initialization
      • initialize

        public InitializationFuture initialize​(java.util.List<AbstractRulesModuleModel> modules,
                                               boolean propagateToOtherNodes,
                                               boolean enableIncrementalUpdate)
        Description copied from interface: RuleEngineService
        Since 6.4 Initializes the given rules module in blocking/async mode (depending on blocking param) (and if propagateToOtherNodes is set to true propagates a RuleEngineInitializedEvent to other nodes).
        Specified by:
        initialize in interface RuleEngineService
        Parameters:
        modules - the modules to be initialized
        propagateToOtherNodes - if true propagates a RuleEngineInitializedEvent to other nodes.
        enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
        Returns:
        instance of InitializationFuture to be used for eventual blocking on multiple parallel swapping
      • initialize

        public InitializationFuture initialize​(java.util.List<AbstractRulesModuleModel> modules,
                                               boolean propagateToOtherNodes,
                                               boolean enableIncrementalUpdate,
                                               ExecutionContext executionContext)
        Description copied from interface: RuleEngineService
        Since 6.7 Initializes the given rules module in blocking/async mode (depending on blocking param) (and if propagateToOtherNodes is set to true propagates a RuleEngineInitializedEvent to other nodes).
        Specified by:
        initialize in interface RuleEngineService
        Parameters:
        modules - the modules to be initialized
        propagateToOtherNodes - if true propagates a RuleEngineInitializedEvent to other nodes.
        enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
        executionContext - instance of ExecutionContext that serves as a storage for initialization related data
        Returns:
        instance of InitializationFuture to be used for eventual blocking on multiple parallel swapping
      • evaluate

        public RuleEvaluationResult evaluate​(RuleEvaluationContext context)
        Description copied from interface: RuleEngineService
        Since 6.0 Executes rule evaluation for given RuleEvaluationContext. Executes all rules contained within the context
        Specified by:
        evaluate in interface RuleEngineService
        Parameters:
        context - the rule engine context containing data about rule engine execution
        Returns:
        results of rule engine execution
      • deactivateRulesModuleEngineRules

        public <T extends AbstractRuleEngineRuleModel> void deactivateRulesModuleEngineRules​(java.lang.String moduleName,
                                                                                             java.util.Collection<T> engineRules)
        Description copied from interface: RuleEngineService
        make the specified collection of engine rules belonging to a specified module inactive, so that the engine wouln't take them in consideration during init
        Specified by:
        deactivateRulesModuleEngineRules in interface RuleEngineService
        Type Parameters:
        T - a type of engine rules
        Parameters:
        moduleName - Name of the module the rules should refer to when applying changes
        engineRules - A collection of AbstractRuleEngineRuleModel to be deactivated
      • addRuleEngineResultRAO

        protected RuleEngineResultRAO addRuleEngineResultRAO​(RuleEvaluationContext context)
        Adds a RuleEngineResultRAO to the facts of this context if it doesn't exist already.
        Parameters:
        context - the rule engine context
        Returns:
        the result rao (already added to the context.facts)
      • provideRAOs

        protected java.util.Set<java.lang.Object> provideRAOs​(FactContext factContext)
      • initializeAllRulesModules

        public java.util.List<RuleEngineActionResult> initializeAllRulesModules​(boolean propagateToOtherNodes)
        Description copied from interface: RuleEngineService
        Initializes all AbstractRulesModuleModels that are marked as active.
        Specified by:
        initializeAllRulesModules in interface RuleEngineService
        Parameters:
        propagateToOtherNodes - if true on all the nodes of cluster
        Returns:
        the activation results
      • getRuleForCodeAndModule

        public AbstractRuleEngineRuleModel getRuleForCodeAndModule​(java.lang.String code,
                                                                   java.lang.String moduleName)
        Description copied from interface: RuleEngineService
        Finds AbstractRuleEngineRuleModel for given code and module.
        Specified by:
        getRuleForCodeAndModule in interface RuleEngineService
        Parameters:
        code - the rule code
        moduleName - the rules module name
        Returns:
        AbstractRuleEngineRuleModel for given code.
      • setAgendaFilterFactory

        public void setAgendaFilterFactory​(AgendaFilterFactory agendaFilterFactory)
      • setAgendaEventListenerFactory

        public void setAgendaEventListenerFactory​(AgendaEventListenerFactory agendaEventListenerFactory)
      • setProcessEventListenerFactory

        public void setProcessEventListenerFactory​(ProcessEventListenerFactory processEventListenerFactory)
      • getRuleConfigurationProvider

        @Deprecated(since="20.05",
                    forRemoval=true)
        protected RAOProvider getRuleConfigurationProvider()
        Deprecated, for removal: This API element is subject to removal in a future version.
        RuleConfigurationRRD is no longer used, instead RuleAndRuleGroupExecutionTracker is used
      • setRuleConfigurationProvider

        @Deprecated(since="20.05",
                    forRemoval=true)
        public void setRuleConfigurationProvider​(RAOProvider ruleConfigurationProvider)
        Deprecated, for removal: This API element is subject to removal in a future version.
        RuleConfigurationRRD is no longer used, instead RuleAndRuleGroupExecutionTracker is used
      • getRuleGroupExecutionProvider

        @Deprecated(since="20.05",
                    forRemoval=true)
        protected RAOProvider getRuleGroupExecutionProvider()
        Deprecated, for removal: This API element is subject to removal in a future version.
        RuleGroupExecutionRRD is no longer used, instead RuleAndRuleGroupExecutionTracker is used
      • setRuleGroupExecutionProvider

        @Deprecated(since="20.05",
                    forRemoval=true)
        public void setRuleGroupExecutionProvider​(RAOProvider ruleGroupExecutionProvider)
        Deprecated, for removal: This API element is subject to removal in a future version.
        RuleGroupExecutionRRD is no longer used, instead RuleAndRuleGroupExecutionTracker is used
      • getPlatformRuleEngineService

        protected RuleEngineService getPlatformRuleEngineService()
      • setEngineRuleDao

        public void setEngineRuleDao​(EngineRuleDao engineRuleDao)
      • setPlatformRuleEngineService

        public void setPlatformRuleEngineService​(RuleEngineService ruleEngineService)
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)
      • setFactContextFactory

        public void setFactContextFactory​(FactContextFactory factContextFactory)
      • setUseDeprecatedRRDsInEvaluations

        @Deprecated(since="20.05",
                    forRemoval=true)
        public void setUseDeprecatedRRDsInEvaluations​(boolean useDeprecatedRRDsInEvaluations)
        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)
      • isUseDeprecatedRRDsInEvaluations

        @Deprecated(since="20.05",
                    forRemoval=true)
        protected boolean isUseDeprecatedRRDsInEvaluations()
        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)