use of org.openksavi.sponge.engine.ProcessorInstanceHolder in project sponge by softelnet.
the class DefaultProcessorManager method doEnable.
protected void doEnable(KnowledgeBase knowledgeBase, Object processorClass, ProcessorType requiredType) {
lock.lock();
try {
ProcessorInstanceHolder instanceHolder = createProcessorInstanceByProcessorClass(knowledgeBase, processorClass, Processor.class);
BaseProcessorAdapter adapter = createAdapter(instanceHolder, requiredType);
bindAdapter(knowledgeBase, instanceHolder.getName(), instanceHolder.getProcessor(), adapter);
initializeProcessor(instanceHolder, adapter);
getRegistrationHandler(adapter.getType()).register(adapter);
} finally {
lock.unlock();
}
}
use of org.openksavi.sponge.engine.ProcessorInstanceHolder in project sponge by softelnet.
the class DefaultProcessorManager method doDisable.
protected void doDisable(KnowledgeBase knowledgeBase, Object processorClass, ProcessorType requiredType) {
lock.lock();
try {
// Creating temporary instance of a processor to resolve its type.
ProcessorInstanceHolder instanceHolder = createProcessorInstanceByProcessorClass(knowledgeBase, processorClass, Processor.class);
BaseProcessorAdapter adapter = createAdapter(instanceHolder, requiredType);
bindAdapter(knowledgeBase, instanceHolder.getName(), instanceHolder.getProcessor(), adapter);
getRegistrationHandler(adapter.getType()).deregister(adapter);
} finally {
lock.unlock();
}
}
use of org.openksavi.sponge.engine.ProcessorInstanceHolder in project sponge by softelnet.
the class DefaultProcessorManager method createProcessorInstanceByProcessorClass.
protected ProcessorInstanceHolder createProcessorInstanceByProcessorClass(KnowledgeBase knowledgeBase, Object processorClass, Class javaClass) {
Validate.notNull(processorClass, "Processor class cannot be null");
ProcessorInstanceHolder result = knowledgeBase.getInterpreter().createProcessorInstanceByProcessorClass(knowledgeBase, processorClass, javaClass);
if (result == null) {
// Try to create an instance using the default (Java-based) knowledge base interpreter.
result = getEngine().getKnowledgeBaseManager().getDefaultKnowledgeBase().getInterpreter().createProcessorInstanceByProcessorClass(knowledgeBase, processorClass, javaClass);
}
if (result == null) {
throw new SpongeException("Unsupported processor class: " + processorClass);
}
return result;
}
Aggregations