I only found the Drools API documentation (http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.4/apidocs/index.html) in which there are mostly java prototypes.

But you can use these lines to see the DRL generated:
   DrlDumper dumper = new DrlDumper();
   System.out.println(dumper.dump(pack));
where pack is a PackageDescr.
So you can try using the API and see whether the result is what you want or not.

   Damien


Neil Goldman a écrit :
I see that you are using the JBRules API to create rules (RuleDescr, ColumnDescr, etc.) Did you find documentation for these classes and methods (other than just the java prototypes) anywhere? thanks,
neil
Neil M. Goldman
Teknowledge Corporation
4640 Admiralty Way, Suite 1010
Marina Del Rey, CA 90292
(310) 578-5350 x204 (voice)
(310) 578-5710 (fax)
[EMAIL PROTECTED]


------------------------------------------------------------------------
*From:* Damien Delautre [mailto:[EMAIL PROTECTED]
*Sent:* Wednesday, November 22, 2006 8:41 AM
*To:* user@drools.codehaus.org
*Subject:* [drools-user] Rules execution ClassLoader

Hello,

I have rules based on a class which is generated dynamically (my rules are also generated dynamically). I have found how to specify the ClassLoader to compile the rules (with the PackageBuilderConfiguration class), but I don't know how to specify the ClassLoader for the execution.
Can anyone tell me how to do this?
I am using JBRules 3.0.4.

Thanks

    Damien

My code:

Class elementClass = ((ListImpl) contact.getList()).getElementClass(clmSession);
            String className = elementClass.getSimpleName();
            String fullClassName = elementClass.getName();
PackageBuilderConfiguration config = new PackageBuilderConfiguration();
            config.setClassLoader(contact.getClass().getClassLoader());
            PackageBuilder builder = new PackageBuilder(config);

PackageDescr pack = new PackageDescr("com.konversation.core.condition");
            pack.addImport(fullClassName);
            RuleDescr ruleDescr = new RuleDescr("Province = QC");
            AndDescr and = new AndDescr();
            ColumnDescr column = new ColumnDescr(className, "contact");
LiteralDescr fieldConstraint = new LiteralDescr("propProvince", "==", "QC");
            column.addDescr(fieldConstraint);
            and.addDescr(column);
            ruleDescr.setLhs(and);
ruleDescr.setConsequence("System.out.println(\"province = QC\");");
            pack.addRule(ruleDescr);
builder.addPackage(pack);
            RuleBase ruleBase = RuleBaseFactory.newRuleBase();
            ruleBase.addPackage( builder.getPackage() );
WorkingMemory workingMemory = ruleBase.newWorkingMemory();
            FactHandle handle = workingMemory.assertObject(contact);
            workingMemory.fireAllRules();

The DRL generated :
            package com.konversation.core.condition;

            import com.konversation.worlds.List67ElementImpl;



            rule "Province = QC"
                 when
                    contact : List67ElementImpl( propProvince == "QC" )

                 then
                    System.out.println("province = QC");
            end

The exception:
java.lang.NoClassDefFoundError: com/konversation/worlds/List67ElementImpl at org.drools.base.com.konversation.worlds.List67ElementImpl$getPropProvince.getValue(Unknown Source) at org.drools.base.ClassFieldExtractor.getValue(Unknown Source) at org.drools.reteoo.AlphaNodeSwitch.getNode(Unknown Source) at org.drools.reteoo.HashedObjectSinkList$1.hasNext(Unknown Source) at org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown Source) at org.drools.reteoo.ObjectTypeNode.assertObject(Unknown Source)
                at org.drools.reteoo.Rete.assertObject(Unknown Source)
at org.drools.reteoo.ReteooRuleBase.assertObject(Unknown Source) at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(Unknown Source) at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source) at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source)

Reply via email to