Search in sources :

Example 1 with DefaultSemanticModule

use of org.drools.core.xml.DefaultSemanticModule in project drools by kiegroup.

the class KnowledgeBuilderConfigurationImpl method loadSemanticModule.

public void loadSemanticModule(Properties properties) {
    String uri = properties.getProperty("uri", null);
    if (uri == null || uri.trim().equals("")) {
        throw new RuntimeException("Semantic Module URI property must not be empty");
    }
    DefaultSemanticModule module = new DefaultSemanticModule(uri);
    for (Entry<Object, Object> entry : properties.entrySet()) {
        String elementName = (String) entry.getKey();
        // uri is processed above, so skip
        if ("uri".equals(elementName)) {
            continue;
        }
        if (elementName == null || elementName.trim().equals("")) {
            throw new RuntimeException("Element name must be specified for Semantic Module handler");
        }
        String handlerName = (String) entry.getValue();
        if (handlerName == null || handlerName.trim().equals("")) {
            throw new RuntimeException("Handler name must be specified for Semantic Module");
        }
        Handler handler = (Handler) ClassUtils.instantiateObject(handlerName, getClassLoader());
        if (handler == null) {
            throw new RuntimeException("Unable to load Semantic Module handler '" + elementName + ":" + handlerName + "'");
        } else {
            module.addHandler(elementName, handler);
        }
    }
    this.semanticModules.addSemanticModule(module);
}
Also used : DefaultSemanticModule(org.drools.core.xml.DefaultSemanticModule) Handler(org.drools.core.xml.Handler)

Aggregations

DefaultSemanticModule (org.drools.core.xml.DefaultSemanticModule)1 Handler (org.drools.core.xml.Handler)1