Interface RuleEngineKieModuleSwapper
-
- All Known Implementing Classes:
DefaultRuleEngineKieModuleSwapper
public interface RuleEngineKieModuleSwapperDrools - specific interface incapsulating the logic of swapping to a new KieContainer during the RuleEngine initialization phase
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringactivateKieModule(DroolsKIEModuleModel module)Updates the instance ofDroolsKIEModuleModelwith information about affectively deployedReleaseIdversionvoidaddKieBase(org.kie.api.builder.model.KieModuleModel module, DroolsKIEBaseModel base)Adds newKieBaseModelto aKieModuleModelwith all rulesvoidaddKieBase(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)Adds newKieBaseModelto aKieModuleModelwith all rulesvoidaddKieSession(org.kie.api.builder.model.KieBaseModel base, DroolsKIESessionModel session)Adds instance of newKieSessionModeltoKieBaseModelvoidaddRules(org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)Adds rules from a givenDroolsKIEBaseModeltoKieFileSystemvoidaddRulesToCache(DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)Add cacheable data of rules of the latest versions belonging to the KieBase into the cache.static MessageLevelconvertLevel(org.kie.api.builder.Message.Level level)converts a drools messageMessage.Levelto aMessageLevel.org.apache.commons.lang3.tuple.Pair<org.kie.api.builder.KieModule,KIEModuleCacheBuilder>createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result)Creates the new instance ofKieModule, based on information contained inDroolsKIEModuleModeljava.util.Optional<org.kie.api.builder.ReleaseId>getDeployedReleaseId(DroolsKIEModuleModel module, java.lang.String deployedMvnVersion)Returns (optional)ReleaseIdfor a deployed version of theKieModuleModelstatic org.kie.api.conf.EqualityBehaviorOptiongetEqualityBehaviorOption(DroolsEqualityBehavior behavior)converts between hybris and drools equality behaviorstatic org.kie.api.conf.EventProcessingOptiongetEventProcessingOption(DroolsEventProcessingMode eventProcessingMode)converts between hybris and drools event processing modeorg.kie.api.builder.ReleaseIdgetReleaseId(DroolsKIEModuleModel module)Creates the new instance ofReleaseIdbased onDroolsKIEModuleModelstatic org.kie.api.builder.model.KieSessionModel.KieSessionTypegetSessionType(DroolsSessionType sessionType)converts between hybris and drools session typeorg.kie.api.runtime.KieContainerinitializeNewKieContainer(DroolsKIEModuleModel module, org.kie.api.builder.KieModule kieModule, RuleEngineActionResult result)Creates the new instance ofKieContainerfor a givenKieModulebooleanremoveKieModuleIfPresent(org.kie.api.builder.ReleaseId releaseId, RuleEngineActionResult result)Tries to remove theKieModulewith givenReleaseIdfromKieRepositorybooleanremoveOldKieModuleIfPresent(RuleEngineActionResult result)Tries to remove the oldKieModulefromKieRepositoryvoidsetUpKieServices()Initializes theKieServicesinstancejava.util.List<java.lang.Object>switchKieModule(DroolsKIEModuleModel module, KieContainerListener listener, java.util.LinkedList<java.util.function.Supplier<java.lang.Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result)Swaps synchroneously to a new KieModule.voidswitchKieModuleAsync(java.lang.String moduleName, KieContainerListener listener, java.util.List<java.lang.Object> resultsAccumulator, java.util.function.Supplier<java.lang.Object> resetFlagSupplier, java.util.List<java.util.function.Supplier<java.lang.Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result)Swaps asynchroneously to a new KieModule.voidwaitForSwappingToFinish()Block until the whole swapping task/tasks are finishedvoidwriteKModuleXML(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs)Creates the XML representation ofKieModuleModeland writes it toKieFileSystemvoidwritePomXML(DroolsKIEModuleModel module, org.kie.api.builder.KieFileSystem kfs)Write the building POM XML toKieFileSystem
-
-
-
Method Detail
-
switchKieModule
java.util.List<java.lang.Object> switchKieModule(DroolsKIEModuleModel module, KieContainerListener listener, java.util.LinkedList<java.util.function.Supplier<java.lang.Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result)
Swaps synchroneously to a new KieModule. It's a blocking call- Parameters:
module- instance of theAbstractRulesModuleModelmodulelistener- instance ofKieContainerListenerthat fires when the switch of Kie Container is completepostTaskList- chain of post-task operations incapsulated as a linked list ofSupplierinstancesenableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- the list that will contain the method execution results including the post-tasks
-
switchKieModuleAsync
void switchKieModuleAsync(java.lang.String moduleName, KieContainerListener listener, java.util.List<java.lang.Object> resultsAccumulator, java.util.function.Supplier<java.lang.Object> resetFlagSupplier, java.util.List<java.util.function.Supplier<java.lang.Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result)Swaps asynchroneously to a new KieModule. It's a non-blocking call- Parameters:
moduleName- kie module namelistener- instance ofKieContainerListenerthat fires when the switch of Kie Container is completeresultsAccumulator- the list that will contain the method execution results including the post-tasksresetFlagSupplier- the task to perform after the sync call finishes the task (whether it was successfull or not )postTaskList- chain of post-task operations incapsulated as a linked list ofSupplierinstancesenableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification
-
initializeNewKieContainer
org.kie.api.runtime.KieContainer initializeNewKieContainer(DroolsKIEModuleModel module, org.kie.api.builder.KieModule kieModule, RuleEngineActionResult result)
Creates the new instance ofKieContainerfor a givenKieModule- Parameters:
module- instance ofDroolsKIEModuleModelkieModule- instance ofKieModuleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- new
KieContainerinstance
-
createKieModule
org.apache.commons.lang3.tuple.Pair<org.kie.api.builder.KieModule,KIEModuleCacheBuilder> createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result)
Creates the new instance ofKieModule, based on information contained inDroolsKIEModuleModel- Parameters:
module- instance ofDroolsKIEModuleModelresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- pair of the newly created instance of
KieModuleand the corresponding caching structure for the created module
-
addKieBase
void addKieBase(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)Adds newKieBaseModelto aKieModuleModelwith all rules- Parameters:
module- instance ofKieModuleModelto add theKieBaseModeltokfs- instance ofKieFileSystembase- instance ofDroolsKIEBaseModelthat keeps the information for aKieBaseModelto be createdcache- the caching structure for the module being initialized
-
addKieBase
void addKieBase(org.kie.api.builder.model.KieModuleModel module, DroolsKIEBaseModel base)Adds newKieBaseModelto aKieModuleModelwith all rules- Parameters:
module- instance ofKieModuleModelto add theKieBaseModeltobase- instance ofDroolsKIEBaseModelthat keeps the information for aKieBaseModelto be created
-
activateKieModule
java.lang.String activateKieModule(DroolsKIEModuleModel module)
Updates the instance ofDroolsKIEModuleModelwith information about affectively deployedReleaseIdversion- Parameters:
module- instance ofDroolsKIEModuleModel- Returns:
- version of deployed
ReleaseId
-
removeKieModuleIfPresent
boolean removeKieModuleIfPresent(org.kie.api.builder.ReleaseId releaseId, RuleEngineActionResult result)Tries to remove theKieModulewith givenReleaseIdfromKieRepository- Parameters:
releaseId- the instance ofReleaseIdcorresponding to aKieModuleto be removedresult- instance ofRuleEngineActionResultto be used in cluster nodes notification removal- Returns:
- true if the module was found and removed, false otherwise
-
removeOldKieModuleIfPresent
boolean removeOldKieModuleIfPresent(RuleEngineActionResult result)
Tries to remove the oldKieModulefromKieRepository- Parameters:
result- instance ofRuleEngineActionResultto be used in cluster nodes notification removal- Returns:
- true if the module was found and removed, false otherwise
-
addKieSession
void addKieSession(org.kie.api.builder.model.KieBaseModel base, DroolsKIESessionModel session)Adds instance of newKieSessionModeltoKieBaseModel- Parameters:
base- instance ofKieBaseModelsession- instance ofDroolsKIESessionModelcontaining the information for newKieSessionModel
-
addRules
void addRules(org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)Adds rules from a givenDroolsKIEBaseModeltoKieFileSystem- Parameters:
kfs- instance ofKieFileSystembase- instance ofDroolsKIEBaseModelcontaining the reference to the rules to publishcache- the caching structure for the module being initialized
-
writeKModuleXML
void writeKModuleXML(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs)Creates the XML representation ofKieModuleModeland writes it toKieFileSystem- Parameters:
module- instance ofKieModuleModelkfs- instance ofKieFileSystem
-
writePomXML
void writePomXML(DroolsKIEModuleModel module, org.kie.api.builder.KieFileSystem kfs)
Write the building POM XML toKieFileSystem- Parameters:
module- instance ofDroolsKIEModuleModelto be used forReleaseIdcreationkfs- instance ofKieFileSystem
-
getReleaseId
org.kie.api.builder.ReleaseId getReleaseId(DroolsKIEModuleModel module)
Creates the new instance ofReleaseIdbased onDroolsKIEModuleModel- Parameters:
module- instance ofDroolsKIEModuleModel- Returns:
- newly created
ReleaseId
-
getDeployedReleaseId
java.util.Optional<org.kie.api.builder.ReleaseId> getDeployedReleaseId(DroolsKIEModuleModel module, java.lang.String deployedMvnVersion)
Returns (optional)ReleaseIdfor a deployed version of theKieModuleModel- Parameters:
module- instance ofDroolsKIEModuleModeldeployedMvnVersion- currently deployed releaseId version of the Kie Module, if known- Returns:
- instance of
Optional.of(ReleaseId) if theReleaseIdcould be created,Optional.empty() otherwise
-
setUpKieServices
void setUpKieServices()
Initializes theKieServicesinstance
-
waitForSwappingToFinish
void waitForSwappingToFinish()
Block until the whole swapping task/tasks are finished
-
addRulesToCache
void addRulesToCache(DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)
Add cacheable data of rules of the latest versions belonging to the KieBase into the cache.- Parameters:
base- KieBase of the rules to be processedcache- CacheBuilder to cache rule data
-
getSessionType
static org.kie.api.builder.model.KieSessionModel.KieSessionType getSessionType(DroolsSessionType sessionType)
converts between hybris and drools session type
-
getEqualityBehaviorOption
static org.kie.api.conf.EqualityBehaviorOption getEqualityBehaviorOption(DroolsEqualityBehavior behavior)
converts between hybris and drools equality behavior
-
getEventProcessingOption
static org.kie.api.conf.EventProcessingOption getEventProcessingOption(DroolsEventProcessingMode eventProcessingMode)
converts between hybris and drools event processing mode
-
convertLevel
static MessageLevel convertLevel(org.kie.api.builder.Message.Level level)
converts a drools messageMessage.Levelto aMessageLevel.
-
-