use of org.openksavi.sponge.core.BaseProcessorDefinition in project sponge by softelnet.
the class DefaultProcessorManager method createProcessorInstance.
@Override
public <T extends Processor> T createProcessorInstance(ProcessorDefinition definition, Class<T> cls) {
Validate.isInstanceOf(BaseProcessorDefinition.class, definition, "Processor definition must be or extend %s", BaseProcessorDefinition.class);
BaseProcessorDefinition baseDefinition = (BaseProcessorDefinition) definition;
if (baseDefinition.isJavaDefined()) {
try {
if (baseDefinition.getProcessorClass() == null) {
throw new SpongeException("No corresponding Java class for processor: " + definition.getName());
}
return (T) baseDefinition.getProcessorClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw SpongeUtils.wrapException(e);
}
} else {
return definition.getKnowledgeBase().getInterpreter().createProcessorInstance(definition.getName(), cls);
}
}
Aggregations