Search in sources :

Example 1 with DialectConfiguration

use of org.drools.compiler.compiler.DialectConfiguration in project drools by kiegroup.

the class KnowledgeBuilderConfigurationImpl method buildDialectRegistry.

public DialectCompiletimeRegistry buildDialectRegistry(ClassLoader rootClassLoader, KnowledgeBuilderConfigurationImpl pkgConf, PackageRegistry pkgRegistry, InternalKnowledgePackage pkg) {
    DialectCompiletimeRegistry registry = new DialectCompiletimeRegistry();
    for (DialectConfiguration conf : this.dialectConfigurations.values()) {
        Dialect dialect = conf.newDialect(rootClassLoader, pkgConf, pkgRegistry, pkg);
        registry.addDialect(dialect.getId(), dialect);
    }
    return registry;
}
Also used : DialectCompiletimeRegistry(org.drools.compiler.compiler.DialectCompiletimeRegistry) DialectConfiguration(org.drools.compiler.compiler.DialectConfiguration) Dialect(org.drools.compiler.compiler.Dialect)

Example 2 with DialectConfiguration

use of org.drools.compiler.compiler.DialectConfiguration in project drools by kiegroup.

the class KnowledgeBuilderConfigurationImpl method init.

private void init(Properties properties) {
    this.chainedProperties = ChainedProperties.getChainedProperties(getClassLoader());
    if (chainedProperties.getProperty("drools.dialect.java", null) == null) {
        // if it couldn't find a conf for java dialect using the project class loader
        // it means it could not load the conf file at all (very likely it is running in
        // an osgi environement) so try with the class loader of this class
        this.chainedProperties = ChainedProperties.getChainedProperties(getClass().getClassLoader());
        if (this.classLoader instanceof ProjectClassLoader) {
            ((ProjectClassLoader) classLoader).setDroolsClassLoader(getClass().getClassLoader());
        }
    }
    if (properties != null) {
        this.chainedProperties.addProperties(properties);
    }
    setProperty(ClassLoaderCacheOption.PROPERTY_NAME, this.chainedProperties.getProperty(ClassLoaderCacheOption.PROPERTY_NAME, "true"));
    setProperty(PropertySpecificOption.PROPERTY_NAME, this.chainedProperties.getProperty(PropertySpecificOption.PROPERTY_NAME, DEFAULT_PROP_SPEC_OPT.toString()));
    setProperty(LanguageLevelOption.PROPERTY_NAME, this.chainedProperties.getProperty(LanguageLevelOption.PROPERTY_NAME, DrlParser.DEFAULT_LANGUAGE_LEVEL.toString()));
    this.dialectConfigurations = new HashMap<String, DialectConfiguration>();
    buildDialectConfigurationMap();
    this.accumulateFunctions = AccumulateUtil.buildAccumulateFunctionsMap(chainedProperties, getClassLoader());
    buildEvaluatorRegistry();
    buildDumpDirectory();
    buildSeverityMap();
    setProperty(ProcessStringEscapesOption.PROPERTY_NAME, this.chainedProperties.getProperty(ProcessStringEscapesOption.PROPERTY_NAME, "true"));
    setProperty(DefaultPackageNameOption.PROPERTY_NAME, this.chainedProperties.getProperty(DefaultPackageNameOption.PROPERTY_NAME, "defaultpkg"));
    this.componentFactory = new DroolsCompilerComponentFactory();
    this.classBuilderFactory = new ClassBuilderFactory();
}
Also used : ProjectClassLoader(org.drools.core.common.ProjectClassLoader) DroolsCompilerComponentFactory(org.drools.compiler.rule.builder.DroolsCompilerComponentFactory) DialectConfiguration(org.drools.compiler.compiler.DialectConfiguration) ClassBuilderFactory(org.drools.core.factmodel.ClassBuilderFactory)

Example 3 with DialectConfiguration

use of org.drools.compiler.compiler.DialectConfiguration in project drools by kiegroup.

the class KnowledgeBuilderConfigurationImpl method addDialect.

public void addDialect(String dialectName, String dialectClass) {
    Class<?> cls = null;
    try {
        cls = getClassLoader().loadClass(dialectClass);
        DialectConfiguration dialectConf = (DialectConfiguration) cls.newInstance();
        dialectConf.init(this);
        addDialect(dialectName, dialectConf);
    } catch (Exception e) {
        throw new RuntimeException("Unable to load dialect '" + dialectClass + ":" + dialectName + ":" + ((cls != null) ? cls.getName() : "null") + "'", e);
    }
}
Also used : DialectConfiguration(org.drools.compiler.compiler.DialectConfiguration)

Aggregations

DialectConfiguration (org.drools.compiler.compiler.DialectConfiguration)3 Dialect (org.drools.compiler.compiler.Dialect)1 DialectCompiletimeRegistry (org.drools.compiler.compiler.DialectCompiletimeRegistry)1 DroolsCompilerComponentFactory (org.drools.compiler.rule.builder.DroolsCompilerComponentFactory)1 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)1 ClassBuilderFactory (org.drools.core.factmodel.ClassBuilderFactory)1