Search in sources :

Example 11 with ClassFieldAccessorCache

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;
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) PackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)

Example 12 with ClassFieldAccessorCache

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);
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) Before(org.junit.Before)

Example 13 with ClassFieldAccessorCache

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);
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) Before(org.junit.Before)

Example 14 with ClassFieldAccessorCache

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());
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) InputStream(java.io.InputStream) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) CodeSource(java.security.CodeSource) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Test(org.junit.Test)

Example 15 with ClassFieldAccessorCache

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);
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) Before(org.junit.Before)

Aggregations

ClassFieldAccessorCache (org.drools.core.base.ClassFieldAccessorCache)34 Before (org.junit.Before)22 ClassFieldAccessorStore (org.drools.core.base.ClassFieldAccessorStore)17 TestBean (org.drools.core.base.TestBean)9 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)9 ClassObjectType (org.drools.core.base.ClassObjectType)7 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)6 MvelConstraintTestUtil (org.drools.core.rule.MvelConstraintTestUtil)6 Pattern (org.drools.core.rule.Pattern)6 WorkingMemory (org.drools.core.WorkingMemory)5 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)5 Consequence (org.drools.core.spi.Consequence)5 KnowledgeHelper (org.drools.core.spi.KnowledgeHelper)5 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)4 IOException (java.io.IOException)3 ObjectInput (java.io.ObjectInput)3 ObjectOutput (java.io.ObjectOutput)3 ClassFieldReader (org.drools.core.base.ClassFieldReader)3 Declaration (org.drools.core.rule.Declaration)3 JavaDialectRuntimeData (org.drools.core.rule.JavaDialectRuntimeData)3