Search in sources :

Example 1 with PackageClassLoader

use of org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader in project drools by kiegroup.

the class ClassBuilderTest method build.

private Class build(ClassBuilder builder, ClassDefinition classDef) throws Exception {
    classLoader = new PackageClassLoader(data, ProjectClassLoader.createProjectClassLoader());
    byte[] d = builder.buildClass(classDef, classLoader);
    data.write(convertClassToResourcePath(classDef.getClassName()), d);
    this.store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(classLoader));
    store.setEagerWire(true);
    Class clazz = classLoader.loadClass(classDef.getClassName());
    classDef.setDefinedClass(clazz);
    return clazz;
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) PackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)

Example 2 with PackageClassLoader

use of org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader in project drools by kiegroup.

the class InstancesHashcodedTest method build.

/*
        <dimension name="bck_cycle_dm"  item-expression="cycleDimension"
                   mode="ignore" cache="10" export-to="cycle_id">
            <id    name="objid"            type="long"             generator-sql="select bck_dimensions_uid.nextval from dual"/>
            <field name="cut_date"         type="java.util.Date"   value="cutDate"     key="true"/>
            <field name="due_date"         type="java.util.Date"   value="dueDate"     key="true"/>
            <field name="cycle_code"       type="java.lang.String" value="cycleCode"/>
            <field name="issue_date"       type="java.util.Date"   value="issueDate"/>
        </dimension>
 */
private Class build(ClassBuilder builder, ClassDefinition classDef) throws Exception {
    ProjectClassLoader prjClassLoader = ProjectClassLoader.createProjectClassLoader();
    byte[] d = builder.buildClass(classDef, prjClassLoader);
    JavaDialectRuntimeData data = new JavaDialectRuntimeData();
    data.write(convertClassToResourcePath(classDef.getClassName()), d);
    ClassLoader classLoader = new PackageClassLoader(data, prjClassLoader);
    ClassFieldAccessorStore store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(classLoader));
    store.setEagerWire(true);
    Class clazz = classLoader.loadClass(classDef.getClassName());
    classDef.setDefinedClass(clazz);
    return clazz;
}
Also used : ProjectClassLoader(org.drools.core.common.ProjectClassLoader) ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) PackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader) ProjectClassLoader(org.drools.core.common.ProjectClassLoader) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) JavaDialectRuntimeData(org.drools.core.rule.JavaDialectRuntimeData) PackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)

Aggregations

ClassFieldAccessorCache (org.drools.core.base.ClassFieldAccessorCache)2 ClassFieldAccessorStore (org.drools.core.base.ClassFieldAccessorStore)2 PackageClassLoader (org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)2 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)1 JavaDialectRuntimeData (org.drools.core.rule.JavaDialectRuntimeData)1