use of org.openksavi.sponge.kb.KnowledgeBase in project sponge by softelnet.
the class DefaultKnowledgeBaseManager method onInitializeKnowledgeBases.
/**
* Initialize knowledge bases.
*/
protected void onInitializeKnowledgeBases() {
for (KnowledgeBase knowledgeBase : knowledgeBases.values()) {
if (knowledgeBase instanceof ScriptKnowledgeBase) {
ScriptKnowledgeBase scriptKnowledgeBase = (ScriptKnowledgeBase) knowledgeBase;
if (knowledgeBase.getType() == null) {
knowledgeBase.setType(inferKnowledgeBaseType(scriptKnowledgeBase.getName(), scriptKnowledgeBase.getScripts()));
}
verifyKnowledgeBaseFileTypes(scriptKnowledgeBase);
}
if (knowledgeBase.getInterpreter() == null) {
knowledgeBase.setInterpreter(createKnowledgeBaseInterpreter(knowledgeBase.getType().getTypeCode(), knowledgeBase));
}
if (knowledgeBase instanceof ScriptKnowledgeBase) {
((ScriptKnowledgeBase) knowledgeBase).load();
}
knowledgeBase.onInit();
}
}
use of org.openksavi.sponge.kb.KnowledgeBase in project sponge by softelnet.
the class DefaultPluginManager method loadPlugin.
/**
* Loads a plugin.
*
* @param pluginStub a plugin stub.
* @return loaded plugin.
*/
protected Plugin loadPlugin(KnowledgeBasePluginStub pluginStub) {
try {
KnowledgeBase knowledgeBase = pluginStub.getKnowledgeBaseName() != null ? getEngine().getKnowledgeBaseManager().getKnowledgeBase(pluginStub.getKnowledgeBaseName()) : getEngine().getKnowledgeBaseManager().getDefaultKnowledgeBase();
Plugin plugin = knowledgeBase.getInterpreter().createPluginInstance(pluginStub.getPluginClassName());
if (pluginStub.getName() != null) {
plugin.setName(pluginStub.getName());
}
plugin.setEngine(getEngine());
plugin.setKnowledgeBase(knowledgeBase);
plugin.setConfiguration(pluginStub.getConfiguration(), true);
return plugin;
} catch (Throwable e) {
throw SpongeUtils.wrapException(e);
}
}
use of org.openksavi.sponge.kb.KnowledgeBase in project sponge by softelnet.
the class DefaultInteractiveMode method getScriptKnowledgeBaseInterpreter.
protected ScriptKnowledgeBaseInterpreter getScriptKnowledgeBaseInterpreter() {
KnowledgeBase knowledgeBase = kbName != null ? engine.getKnowledgeBaseManager().getKnowledgeBase(kbName) : engine.getKnowledgeBaseManager().getMainKnowledgeBase();
KnowledgeBaseInterpreter interpreter = knowledgeBase.getInterpreter();
if (!(interpreter instanceof ScriptKnowledgeBaseInterpreter)) {
throw new SpongeException("Knowledge base '" + kbName + "' is not script-based.");
}
return (ScriptKnowledgeBaseInterpreter) interpreter;
}
Aggregations