Class DefaultCommerceRuleEngineService
- java.lang.Object
-
- de.hybris.platform.droolsruleengineservices.impl.DefaultCommerceRuleEngineService
-
- All Implemented Interfaces:
RuleEngineService
public class DefaultCommerceRuleEngineService extends java.lang.Object implements RuleEngineService
Default implementation of Commerce Rule Engine Service.
-
-
Constructor Summary
Constructors Constructor Description DefaultCommerceRuleEngineService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected RuleEngineResultRAOaddRuleEngineResultRAO(RuleEvaluationContext context)Adds a RuleEngineResultRAO to the facts of this context if it doesn't exist already.RuleEngineActionResultarchiveRule(AbstractRuleEngineRuleModel ruleEngineRule)Deprecated, for removal: This API element is subject to removal in a future version.since 1811RuleEngineActionResultarchiveRule(AbstractRuleEngineRuleModel ruleEngineRule, AbstractRulesModuleModel rulesModule)Deprecated, for removal: This API element is subject to removal in a future version.since 1811<T extends DroolsRuleModel>
java.util.Optional<InitializationFuture>archiveRules(java.util.Collection<T> engineRules)Archive a collection of rules<T extends AbstractRuleEngineRuleModel>
voiddeactivateRulesModuleEngineRules(java.lang.String moduleName, java.util.Collection<T> engineRules)make the specified collection of engine rules belonging to a specified module inactive, so that the engine wouln't take them in consideration during initRuleEvaluationResultevaluate(RuleEvaluationContext context)Since 6.0 Executes rule evaluation for given RuleEvaluationContext.protected AgendaEventListenerFactorygetAgendaEventListenerFactory()protected AgendaFilterFactorygetAgendaFilterFactory()protected ConfigurationServicegetConfigurationService()protected EngineRuleDaogetEngineRuleDao()protected java.util.Set<java.lang.Object>getEventListners(DroolsRuleEngineContextModel ruleEngineContext)protected FactContextFactorygetFactContextFactory()protected RuleEngineServicegetPlatformRuleEngineService()protected ProcessEventListenerFactorygetProcessEventListenerFactory()protected RAOProvidergetRuleConfigurationProvider()AbstractRuleEngineRuleModelgetRuleForCodeAndModule(java.lang.String code, java.lang.String moduleName)Finds AbstractRuleEngineRuleModel for given code and module.AbstractRuleEngineRuleModelgetRuleForUuid(java.lang.String uuid)Finds AbstractRuleEngineRuleModel for given uuid.protected RAOProvidergetRuleGroupExecutionProvider()protected RuleRuntimeEventListenerFactorygetRuleRuntimeEventListenerFactory()voidinitialize(AbstractRulesModuleModel module, java.lang.String deployedMvnVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result)Since 6.4 Initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).voidinitialize(AbstractRulesModuleModel module, java.lang.String deployedMvnVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result, ExecutionContext executionContext)Since 18.08 Initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).InitializationFutureinitialize(java.util.List<AbstractRulesModuleModel> modules, boolean propagateToOtherNodes, boolean enableIncrementalUpdate)Since 6.4 Initializes the given rules module in blocking/async mode (depending on blocking param) (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).InitializationFutureinitialize(java.util.List<AbstractRulesModuleModel> modules, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, ExecutionContext executionContext)Since 6.7 Initializes the given rules module in blocking/async mode (depending on blocking param) (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).java.util.List<RuleEngineActionResult>initializeAllRulesModules()Initializes allAbstractRulesModuleModels that are marked as active (in case of cluster mode - on all the nodes).java.util.List<RuleEngineActionResult>initializeAllRulesModules(boolean propagateToOtherNodes)Initializes allAbstractRulesModuleModels that are marked as active.voidinitializeNonBlocking(AbstractRulesModuleModel module, java.lang.String deployedReleaseIdVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result)Since 6.4 Asynchronously initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).protected voidlogContextFacts(RuleEvaluationContext context)protected java.util.Set<java.lang.Object>provideRAOs(FactContext factContext)voidsetAgendaEventListenerFactory(AgendaEventListenerFactory agendaEventListenerFactory)voidsetAgendaFilterFactory(AgendaFilterFactory agendaFilterFactory)voidsetConfigurationService(ConfigurationService configurationService)voidsetEngineRuleDao(EngineRuleDao engineRuleDao)voidsetFactContextFactory(FactContextFactory factContextFactory)voidsetPlatformRuleEngineService(RuleEngineService ruleEngineService)voidsetProcessEventListenerFactory(ProcessEventListenerFactory processEventListenerFactory)voidsetRuleConfigurationProvider(RAOProvider ruleConfigurationProvider)voidsetRuleGroupExecutionProvider(RAOProvider ruleGroupExecutionProvider)voidsetRuleRuntimeEventListenerFactory(RuleRuntimeEventListenerFactory ruleRuntimeEventListenerFactory)RuleEngineActionResultupdateEngineRule(AbstractRuleEngineRuleModel ruleEngineRule, AbstractRulesModuleModel rulesModule)Updates the given rule if it already exists.
-
-
-
Method Detail
-
initialize
public void initialize(AbstractRulesModuleModel module, java.lang.String deployedMvnVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result)
Description copied from interface:RuleEngineServiceSince 6.4 Initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).- Specified by:
initializein interfaceRuleEngineService- Parameters:
module- the module to be initializeddeployedMvnVersion- currently deployed mvn version of the rule engine modulepropagateToOtherNodes- if true propagates aRuleEngineInitializedEventto other nodes.enableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- the instance ofRuleEngineActionResultaccumulating the results of initialization
-
initialize
public void initialize(AbstractRulesModuleModel module, java.lang.String deployedMvnVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result, ExecutionContext executionContext)
Description copied from interface:RuleEngineServiceSince 18.08 Initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).- Specified by:
initializein interfaceRuleEngineService- Parameters:
module- the module to be initializeddeployedMvnVersion- currently deployed mvn version of the rule engine modulepropagateToOtherNodes- if true propagates aRuleEngineInitializedEventto other nodes.enableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- the instance ofRuleEngineActionResultaccumulating the results of initializationexecutionContext- the instance ofExecutionContextto be set as executionContext ofRuleEngineActionResultif not null
-
initializeNonBlocking
public void initializeNonBlocking(AbstractRulesModuleModel module, java.lang.String deployedReleaseIdVersion, boolean propagateToOtherNodes, boolean enableIncrementalUpdate, RuleEngineActionResult result)
Description copied from interface:RuleEngineServiceSince 6.4 Asynchronously initializes the given rules module (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).- Specified by:
initializeNonBlockingin interfaceRuleEngineService- Parameters:
module- the module to be initializeddeployedReleaseIdVersion- currently deployed version of the Kie ModulepropagateToOtherNodes- if true propagates aRuleEngineInitializedEventto other nodes.enableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- the instance ofRuleEngineActionResultaccumulating the results of initialization
-
initialize
public InitializationFuture initialize(java.util.List<AbstractRulesModuleModel> modules, boolean propagateToOtherNodes, boolean enableIncrementalUpdate)
Description copied from interface:RuleEngineServiceSince 6.4 Initializes the given rules module in blocking/async mode (depending on blocking param) (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).- Specified by:
initializein interfaceRuleEngineService- Parameters:
modules- the modules to be initializedpropagateToOtherNodes- if true propagates aRuleEngineInitializedEventto other nodes.enableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie module- Returns:
- instance of
InitializationFutureto 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:RuleEngineServiceSince 6.7 Initializes the given rules module in blocking/async mode (depending on blocking param) (and ifpropagateToOtherNodesis set totruepropagates aRuleEngineInitializedEventto other nodes).- Specified by:
initializein interfaceRuleEngineService- Parameters:
modules- the modules to be initializedpropagateToOtherNodes- if true propagates aRuleEngineInitializedEventto other nodes.enableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleexecutionContext- instance ofExecutionContextthat serves as a storage for initialization related data- Returns:
- instance of
InitializationFutureto be used for eventual blocking on multiple parallel swapping
-
evaluate
public RuleEvaluationResult evaluate(RuleEvaluationContext context)
Description copied from interface:RuleEngineServiceSince 6.0 Executes rule evaluation for given RuleEvaluationContext. Executes all rules contained within the context- Specified by:
evaluatein interfaceRuleEngineService- 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:RuleEngineServicemake 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:
deactivateRulesModuleEngineRulesin interfaceRuleEngineService- Type Parameters:
T- a type of engine rules- Parameters:
moduleName- Name of the module the rules should refer to when applying changesengineRules- A collection ofAbstractRuleEngineRuleModelto be deactivated
-
logContextFacts
protected void logContextFacts(RuleEvaluationContext context)
-
getEventListners
protected java.util.Set<java.lang.Object> getEventListners(DroolsRuleEngineContextModel ruleEngineContext)
-
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()
Description copied from interface:RuleEngineServiceInitializes allAbstractRulesModuleModels that are marked as active (in case of cluster mode - on all the nodes).- Specified by:
initializeAllRulesModulesin interfaceRuleEngineService- Returns:
- the results of the initialize action (use
RuleEngineActionResult.isActionFailed()to check if the action succeeded)
-
initializeAllRulesModules
public java.util.List<RuleEngineActionResult> initializeAllRulesModules(boolean propagateToOtherNodes)
Description copied from interface:RuleEngineServiceInitializes allAbstractRulesModuleModels that are marked as active.- Specified by:
initializeAllRulesModulesin interfaceRuleEngineService- Parameters:
propagateToOtherNodes- if true on all the nodes of cluster- Returns:
- the activation results
-
updateEngineRule
public RuleEngineActionResult updateEngineRule(AbstractRuleEngineRuleModel ruleEngineRule, AbstractRulesModuleModel rulesModule)
Description copied from interface:RuleEngineServiceUpdates the given rule if it already exists.- Specified by:
updateEngineRulein interfaceRuleEngineService- Parameters:
ruleEngineRule- Rule to be updatedrulesModule-AbstractRulesModuleModelwhere the Rule be updated- Returns:
- the result of the update action (use
RuleEngineActionResult.isActionFailed()to check if the action succeeded)
-
archiveRule
@Deprecated(since="1811", forRemoval=true) public RuleEngineActionResult archiveRule(AbstractRuleEngineRuleModel ruleEngineRule)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Description copied from interface:RuleEngineServiceArchives the given rule if it already exists.- Specified by:
archiveRulein interfaceRuleEngineService- Parameters:
ruleEngineRule- Rule to be archived- Returns:
- the result of the archive action (use
RuleEngineActionResult.isActionFailed()to check if the action succeeded)
-
archiveRule
@Deprecated(since="1811", forRemoval=true) public RuleEngineActionResult archiveRule(AbstractRuleEngineRuleModel ruleEngineRule, AbstractRulesModuleModel rulesModule)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Description copied from interface:RuleEngineServiceArchives the given rule if it already exists.- Specified by:
archiveRulein interfaceRuleEngineService- Parameters:
ruleEngineRule- Rule to be archivedrulesModule-AbstractRulesModuleModelwhere the Rule is archived- Returns:
- the result of the archive action (use
RuleEngineActionResult.isActionFailed()to check if the action succeeded)
-
archiveRules
public <T extends DroolsRuleModel> java.util.Optional<InitializationFuture> archiveRules(java.util.Collection<T> engineRules)
Description copied from interface:RuleEngineServiceArchive a collection of rules- Specified by:
archiveRulesin interfaceRuleEngineService- Type Parameters:
T- subtype ofDroolsRuleModel- Parameters:
engineRules- collection ofDroolsRuleModelinstances- Returns:
- optional of
InitializationFuturekeeping the status of initialization
-
getRuleForCodeAndModule
public AbstractRuleEngineRuleModel getRuleForCodeAndModule(java.lang.String code, java.lang.String moduleName)
Description copied from interface:RuleEngineServiceFinds AbstractRuleEngineRuleModel for given code and module.- Specified by:
getRuleForCodeAndModulein interfaceRuleEngineService- Parameters:
code- the rule codemoduleName- the rules module name- Returns:
- AbstractRuleEngineRuleModel for given code.
-
getRuleForUuid
public AbstractRuleEngineRuleModel getRuleForUuid(java.lang.String uuid)
Description copied from interface:RuleEngineServiceFinds AbstractRuleEngineRuleModel for given uuid.- Specified by:
getRuleForUuidin interfaceRuleEngineService- Parameters:
uuid- the rule uuid- Returns:
- AbstractRuleEngineRuleModel for given uuid.
-
getAgendaFilterFactory
protected AgendaFilterFactory getAgendaFilterFactory()
-
setAgendaFilterFactory
public void setAgendaFilterFactory(AgendaFilterFactory agendaFilterFactory)
-
getAgendaEventListenerFactory
protected AgendaEventListenerFactory getAgendaEventListenerFactory()
-
setAgendaEventListenerFactory
public void setAgendaEventListenerFactory(AgendaEventListenerFactory agendaEventListenerFactory)
-
getProcessEventListenerFactory
protected ProcessEventListenerFactory getProcessEventListenerFactory()
-
setProcessEventListenerFactory
public void setProcessEventListenerFactory(ProcessEventListenerFactory processEventListenerFactory)
-
getRuleRuntimeEventListenerFactory
protected RuleRuntimeEventListenerFactory getRuleRuntimeEventListenerFactory()
-
setRuleRuntimeEventListenerFactory
public void setRuleRuntimeEventListenerFactory(RuleRuntimeEventListenerFactory ruleRuntimeEventListenerFactory)
-
getRuleConfigurationProvider
protected RAOProvider getRuleConfigurationProvider()
-
setRuleConfigurationProvider
public void setRuleConfigurationProvider(RAOProvider ruleConfigurationProvider)
-
getRuleGroupExecutionProvider
protected RAOProvider getRuleGroupExecutionProvider()
-
setRuleGroupExecutionProvider
public void setRuleGroupExecutionProvider(RAOProvider ruleGroupExecutionProvider)
-
getPlatformRuleEngineService
protected RuleEngineService getPlatformRuleEngineService()
-
getEngineRuleDao
protected EngineRuleDao getEngineRuleDao()
-
setEngineRuleDao
public void setEngineRuleDao(EngineRuleDao engineRuleDao)
-
setPlatformRuleEngineService
public void setPlatformRuleEngineService(RuleEngineService ruleEngineService)
-
getConfigurationService
protected ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
getFactContextFactory
protected FactContextFactory getFactContextFactory()
-
setFactContextFactory
public void setFactContextFactory(FactContextFactory factContextFactory)
-
-