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;
}
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();
}
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);
}
}
Aggregations