public class DefaultRuleEngineKieModuleSwapper extends Object implements RuleEngineKieModuleSwapper
RuleEngineKieModuleSwapper interface| Modifier and Type | Field and Description |
|---|---|
static String |
WORKER_PRE_DESTROY_TIMEOUT |
| Constructor and Description |
|---|
DefaultRuleEngineKieModuleSwapper() |
| Modifier and Type | Method and Description |
|---|---|
String |
activateKieModule(DroolsKIEModuleModel module)
Updates the instance of
DroolsKIEModuleModel with information about affectively deployed ReleaseId
version |
void |
addKieBase(KieModuleModel module,
KieFileSystem kfs,
DroolsKIEBaseModel base,
KIEModuleCacheBuilder cache)
Adds new
KieBaseModel to a KieModuleModel with all rules |
void |
addKieSession(KieBaseModel base,
DroolsKIESessionModel session)
Adds instance of new
KieSessionModel to KieBaseModel |
protected ResultItem |
addNewResultItemOf(RuleEngineActionResult result,
MessageLevel messageLevel,
String message) |
void |
addRules(KieFileSystem kfs,
DroolsKIEBaseModel base,
KIEModuleCacheBuilder cache)
Adds rules from a given
DroolsKIEBaseModel to KieFileSystem |
void |
beforeDestroy()
This method to be called by containers (like spring container) as destroy method
|
<any> |
createKieModule(DroolsKIEModuleModel module,
RuleEngineActionResult result)
Creates the new instance of
KieModule, based on information contained in DroolsKIEModuleModel |
protected ConcurrentMapFactory |
getConcurrentMapFactory() |
protected ConfigurationService |
getConfigurationService() |
protected Tenant |
getCurrentTenant() |
Optional<ReleaseId> |
getDeployedReleaseId(DroolsKIEModuleModel module,
String deployedMvnVersion)
Returns (optional)
ReleaseId for a deployed version of the KieModuleModel |
protected KieServices |
getKieServices() |
protected ModelService |
getModelService() |
ReleaseId |
getReleaseId(DroolsKIEModuleModel module)
Creates the new instance of
ReleaseId based on DroolsKIEModuleModel |
protected RuleEngineCacheService |
getRuleEngineCacheService() |
protected RulesModuleDao |
getRulesModuleDao() |
protected ThreadFactory |
getTenantAwareThreadFactory() |
protected long |
getWorkerPreDestroyTimeout() |
protected void |
initializeNewModule(DroolsKIEModuleModel droolsKIEModuleModel,
RuleEngineActionResult result,
KieContainerListener listener) |
protected boolean |
isInitialEngineStartup(ReleaseId releaseId,
String newDeployedMvnVersion) |
protected void |
registerWorker(String moduleName,
Thread worker) |
boolean |
removeKieModuleIfPresent(ReleaseId releaseId,
RuleEngineActionResult result)
Tries to remove the
KieModule with given ReleaseId from org.kie.api.builder.KieRepository |
void |
setConcurrentMapFactory(ConcurrentMapFactory concurrentMapFactory) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setCurrentTenant(Tenant currentTenant) |
protected void |
setKieServices(KieServices kieServices) |
void |
setModelService(ModelService modelService) |
void |
setRuleEngineCacheService(RuleEngineCacheService ruleEngineCacheService) |
void |
setRulesModuleDao(RulesModuleDao rulesModuleDao) |
void |
setTenantAwareThreadFactory(ThreadFactory tenantAwareThreadFactory) |
void |
setup() |
void |
setUpKieServices()
Initializes the
org.kie.api.KieServices instance |
List<Object> |
switchKieModule(DroolsKIEModuleModel module,
RuleEngineActionResult result,
KieContainerListener listener,
LinkedList<Supplier<Object>> postTaskList)
Swaps synchroneously to a new KieModule.
|
void |
switchKieModuleAsync(String moduleName,
RuleEngineActionResult result,
KieContainerListener listener,
List<Object> resultsAccumulator,
LinkedList<Supplier<Object>> postTaskList)
Swaps asynchroneously to a new KieModule.
|
protected Runnable |
switchKieModuleRunnableTask(String moduleName,
RuleEngineActionResult result,
KieContainerListener listener,
List<Object> resultsAccumulator,
LinkedList<Supplier<Object>> postTaskList) |
void |
waitForSwappingToFinish()
Block until the whole swapping task/tasks are finished
|
protected void |
waitWhileWorkerIsRunning(Thread worker) |
void |
writeKModuleXML(KieModuleModel module,
KieFileSystem kfs)
Creates the XML representation of
KieModuleModel and writes it to KieFileSystem |
void |
writePomXML(DroolsKIEModuleModel module,
KieFileSystem kfs)
Write the building POM XML to
KieFileSystem |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertLevel, getEqualityBehaviorOption, getEventProcessingOption, getSessionTypepublic static final String WORKER_PRE_DESTROY_TIMEOUT
public List<Object> switchKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result, KieContainerListener listener, LinkedList<Supplier<Object>> postTaskList)
RuleEngineKieModuleSwapperswitchKieModule in interface RuleEngineKieModuleSwappermodule - instance of the AbstractRulesModuleModel moduleresult - instance of RuleEngineActionResult to be used in cluster nodes notificationlistener - instance of KieContainerListener that fires when the switch of Kie Container is completepostTaskList - chain of post-task operations incapsulated as a linked list of Supplier instancespublic void switchKieModuleAsync(String moduleName, RuleEngineActionResult result, KieContainerListener listener, List<Object> resultsAccumulator, LinkedList<Supplier<Object>> postTaskList)
RuleEngineKieModuleSwapperswitchKieModuleAsync in interface RuleEngineKieModuleSwappermoduleName - kie module nameresult - instance of RuleEngineActionResult to be used in cluster nodes notificationlistener - instance of KieContainerListener that fires when the switch of Kie Container is completeresultsAccumulator - the list that will contain the method execution results including the post-taskspostTaskList - chain of post-task operations incapsulated as a linked list of Supplier instancespublic void waitForSwappingToFinish()
RuleEngineKieModuleSwapperwaitForSwappingToFinish in interface RuleEngineKieModuleSwapperprotected void waitWhileWorkerIsRunning(Thread worker)
public void beforeDestroy()
public void writeKModuleXML(KieModuleModel module,
KieFileSystem kfs)
RuleEngineKieModuleSwapperKieModuleModel and writes it to KieFileSystemwriteKModuleXML in interface RuleEngineKieModuleSwappermodule - instance of KieModuleModelkfs - instance of KieFileSystempublic void writePomXML(DroolsKIEModuleModel module, KieFileSystem kfs)
RuleEngineKieModuleSwapperKieFileSystemwritePomXML in interface RuleEngineKieModuleSwappermodule - instance of DroolsKIEModuleModel to be used for ReleaseId creationkfs - instance of KieFileSystempublic ReleaseId getReleaseId(DroolsKIEModuleModel module)
RuleEngineKieModuleSwapperReleaseId based on DroolsKIEModuleModelgetReleaseId in interface RuleEngineKieModuleSwappermodule - instance of DroolsKIEModuleModelReleaseIdpublic <any> createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result) throws DroolsInitializationException
RuleEngineKieModuleSwapperKieModule, based on information contained in DroolsKIEModuleModelcreateKieModule in interface RuleEngineKieModuleSwappermodule - instance of DroolsKIEModuleModelresult - instance of RuleEngineActionResult to be used in cluster nodes notificationKieModule and the corresponding caching structure for the
created moduleDroolsInitializationExceptionpublic void addKieBase(KieModuleModel module,
KieFileSystem kfs,
DroolsKIEBaseModel base,
KIEModuleCacheBuilder cache)
RuleEngineKieModuleSwapperKieBaseModel to a KieModuleModel with all rulesaddKieBase in interface RuleEngineKieModuleSwappermodule - instance of KieModuleModel to add the KieBaseModel tokfs - instance of KieFileSystembase - instance of DroolsKIEBaseModel that keeps the information for a KieBaseModel to be
createdcache - the caching structure for the module being initializedpublic void addKieSession(KieBaseModel base,
DroolsKIESessionModel session)
RuleEngineKieModuleSwapperKieSessionModel to KieBaseModeladdKieSession in interface RuleEngineKieModuleSwapperbase - instance of KieBaseModelsession - instance of DroolsKIESessionModel containing the information for new KieSessionModelpublic String activateKieModule(DroolsKIEModuleModel module)
RuleEngineKieModuleSwapperDroolsKIEModuleModel with information about affectively deployed ReleaseId
versionactivateKieModule in interface RuleEngineKieModuleSwappermodule - instance of DroolsKIEModuleModelReleaseIdpublic boolean removeKieModuleIfPresent(ReleaseId releaseId,
RuleEngineActionResult result)
RuleEngineKieModuleSwapperKieModule with given ReleaseId from org.kie.api.builder.KieRepositoryremoveKieModuleIfPresent in interface RuleEngineKieModuleSwapperreleaseId - the instance of ReleaseId corresponding to a KieModule to be removedresult - instance of RuleEngineActionResult to be used in cluster nodes notification
removalpublic void addRules(KieFileSystem kfs,
DroolsKIEBaseModel base,
KIEModuleCacheBuilder cache)
RuleEngineKieModuleSwapperDroolsKIEBaseModel to KieFileSystemaddRules in interface RuleEngineKieModuleSwapperkfs - instance of KieFileSystembase - instance of DroolsKIEBaseModel containing the reference to the rules to publishcache - the caching structure for the module being initializedpublic Optional<ReleaseId> getDeployedReleaseId(DroolsKIEModuleModel module, String deployedMvnVersion)
RuleEngineKieModuleSwapperReleaseId for a deployed version of the KieModuleModelgetDeployedReleaseId in interface RuleEngineKieModuleSwappermodule - instance of DroolsKIEModuleModeldeployedMvnVersion - currently deployed releaseId version of the Kie Module, if knownOptional.of(ReleaseId) if the ReleaseId could be created,
Optional.empty() otherwisepublic void setUpKieServices()
RuleEngineKieModuleSwapperorg.kie.api.KieServices instancesetUpKieServices in interface RuleEngineKieModuleSwapper@PostConstruct public void setup()
protected void initializeNewModule(DroolsKIEModuleModel droolsKIEModuleModel, RuleEngineActionResult result, KieContainerListener listener)
protected ResultItem addNewResultItemOf(RuleEngineActionResult result, MessageLevel messageLevel, String message)
protected Runnable switchKieModuleRunnableTask(String moduleName, RuleEngineActionResult result, KieContainerListener listener, List<Object> resultsAccumulator, LinkedList<Supplier<Object>> postTaskList)
protected boolean isInitialEngineStartup(ReleaseId releaseId,
String newDeployedMvnVersion)
protected KieServices getKieServices()
protected void setKieServices(KieServices kieServices)
protected ConfigurationService getConfigurationService()
public void setConfigurationService(ConfigurationService configurationService)
protected Tenant getCurrentTenant()
public void setCurrentTenant(Tenant currentTenant)
protected ThreadFactory getTenantAwareThreadFactory()
public void setTenantAwareThreadFactory(ThreadFactory tenantAwareThreadFactory)
protected ModelService getModelService()
public void setModelService(ModelService modelService)
protected RuleEngineCacheService getRuleEngineCacheService()
public void setRuleEngineCacheService(RuleEngineCacheService ruleEngineCacheService)
protected RulesModuleDao getRulesModuleDao()
public void setRulesModuleDao(RulesModuleDao rulesModuleDao)
protected ConcurrentMapFactory getConcurrentMapFactory()
public void setConcurrentMapFactory(ConcurrentMapFactory concurrentMapFactory)
protected long getWorkerPreDestroyTimeout()
Copyright © 2017 SAP SE. All Rights Reserved.