The KnowledgeBuilder processes the declared types in a DRL file,
creating the bytecode on the fly.
When the knowledge package is added to a knowledge base, the newly
created class descriptor
(the FactType and its related components) become part of the KB and the
actual class is (re)loaded by
the KB's classloader.
Since the dynamic class is not available until runtime, the "Type"
descriptors give you a reflection-like
API to manipulate the instances. This said:
Step 1: I'd actually get **the** KB which is being used to spawn
sessions, to make sure you are using
the same classes, as loaded by the same classloader.
Step 2: The FactType also holds a reference to the loaded class, you can
get it using FactType.getDefinedClass(), if needed
Step 3: it's not really a step: it means that the next two steps (4+5)
are just an example of what you can
do now that you have the Type reference.
Best,
Davide
On 02/27/2013 03:36 PM, IPatel wrote:
Hi,
Basic questions on the facts that are created in Guvnor using New
Declaritive Model
I have the facts that are created in Guvnor which i dont have java classes
defined. I am refering to the tutorial provided on Chapter 5 The Fact Model
and in that it shows how to use the declarative facts from Java.
I am having hard time following the steps. So i am going to layout below to
see if my understanding is correct:
Step 1: // get a reference to a knowledge base with a declared type:
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
Step 2:// get the declared FactType
FactType personType = kbase.getFactType( "PackageName", "FactName"
);
Step 3:// handle the type as necessary:
Not sure what this means
Step 4:// create instances:
Object bob = personType.newInstance();
Step5: // set attributes values
personType.set( bob,
"name",
"Bob" );
Step 6: // insert fact into a session
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Step 7:ksession.insert( bob );
Step 8:ksession.fireAllRules();
I am able to understand Step 4 thru Step 8. I guess i am having trouble
understanding step 1 and Step 3.
Can someone please help me clarify or have example for me to refer.
--
View this message in context:
http://drools.46999.n3.nabble.com/How-to-integrate-Declarative-Fact-creat...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users