use of org.drools.core.base.ClassFieldAccessorCache 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;
}
use of org.drools.core.base.ClassFieldAccessorCache in project drools by kiegroup.
the class RightTupleIndexHashTableTest method setUp.
@Before
public void setUp() throws Exception {
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
}
use of org.drools.core.base.ClassFieldAccessorCache in project drools by kiegroup.
the class FieldConstraintTest method setUp.
@Before
public void setUp() throws Exception {
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
}
use of org.drools.core.base.ClassFieldAccessorCache in project drools by kiegroup.
the class PackageCompilationDataTest method testCodeSourceUrl.
@Test
public void testCodeSourceUrl() throws Exception {
final String className = TestEvalExpression.class.getName();
KnowledgeBaseImpl kBase = new KnowledgeBaseImpl("xxx", null);
InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.drools");
pkg.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
JavaDialectRuntimeData data = new JavaDialectRuntimeData();
data.onAdd(pkg.getDialectRuntimeRegistry(), kBase.getRootClassLoader());
pkg.getDialectRuntimeRegistry().setDialectData("java", data);
kBase.addPackage(pkg);
final JavaDialectRuntimeData pcData = (JavaDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData("java");
final EvalCondition invoker = new EvalCondition(null);
pcData.putInvoker(className, invoker);
final InputStream is = getClass().getClassLoader().getResourceAsStream(className.replace('.', '/') + ".class");
try {
pcData.write(className.replace('.', '/') + ".class", read(is));
} finally {
is.close();
}
pcData.onAdd(pkg.getDialectRuntimeRegistry(), kBase.getRootClassLoader());
pcData.onBeforeExecute();
Class cls = kBase.getRootClassLoader().loadClass("org.drools.core.rule.PackageCompilationDataTest$TestEvalExpression");
final CodeSource codeSource = invoker.getEvalExpression().getClass().getProtectionDomain().getCodeSource();
assertNotNull(codeSource.getLocation());
}
use of org.drools.core.base.ClassFieldAccessorCache in project drools by kiegroup.
the class FieldIndexEntryTest method setUp.
@Before
public void setUp() throws Exception {
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
}
Aggregations