@SuppressWarnings({ "unchecked" }) @Override public void ungetHandler(Module module, String childModulePrefix, ModuleHandler handler) { ModuleHandler handlerOfModule = getHandlers().get(childModulePrefix + module.getId()); if (handlerOfModule instanceof AbstractCompositeModuleHandler) { AbstractCompositeModuleHandler<ModuleImpl, ?, ?> h = (AbstractCompositeModuleHandler<ModuleImpl, ?, ?>) handlerOfModule; Set<ModuleImpl> modules = h.moduleHandlerMap.keySet(); if (modules != null) { for (ModuleImpl child : modules) { ModuleHandler childHandler = h.moduleHandlerMap.get(child); ModuleHandlerFactory mhf = ruleEngine.getModuleHandlerFactory(child.getTypeUID()); mhf.ungetHandler(child, childModulePrefix + ":" + module.getId(), childHandler); } } } String ruleId = getRuleId(childModulePrefix); super.ungetHandler(module, ruleId, handler); }
/** * Unlink module handlers from their modules. The method is called when the rule containing these modules goes into * {@link RuleStatus#UNINITIALIZED} state. * * @param modules list of modules which should be disconnected. */ private <T extends WrappedModule<?, ?>> void removeModuleHandlers(List<T> modules, String ruleUID) { for (T mm : modules) { final Module m = mm.unwrap(); ModuleHandler handler = mm.getModuleHandler(); if (handler != null) { ModuleHandlerFactory factory = getModuleHandlerFactory(m.getTypeUID()); if (factory != null) { factory.ungetHandler(m, ruleUID, handler); } mm.setModuleHandler(null); } } }