Michal is correct from the point of view of the application. That is required because the actual classes are generated at compile time and not visible to the application classpath.
Although, that is not the only way. Inside your rules, they are visible and you instantiate them the same way as you instantiate any other java Pojo:
rule xyz
when
// sometihng
then
Person p = new Person();
p.setName( "Bob" );
insert( p );
end
Also, if you use Guvnor to define your model, Guvnor is capable of generating a jar file for you with the generated classes. This way you can download the jar and add it to the classpath of your application and use it as any POJOs too.
[]s
Edson
Look at this unit test for some examples:// Retrieve the generated fact typeFactType cheeseFact = ruleBase.getFactType( "org.drools.generatedbeans.Cheese" );// Create a new Fact instanceObject cheese = cheeseFact.newInstance();// Set a field value using the more verbose method chain...// should we add short cuts?// cheeseFact.getField( "type" ).getFieldAccessor().setValue( cheese,// "stilton" );cheeseFact.set( cheese,"type","stilton" );assertEquals( "stilton",cheeseFact.get( cheese,"type" ) );On Tue, Jan 27, 2009 at 2:02 AM, Oleg Zenzin <zenzin@intalio.com> wrote:
_______________________________________________There's now possibility to declare facts in the drl, like:
declare Person
name: String
age: int
endMy question is how do I instantiate this fact object during runtime? Do I still need to have class Person compiled and existing somewhere in classpath, or there's a helper class which I can use "fake the fact", something like:
FakeFact person = FakeFact("Person");
person.setField("name", "Oleg");
person.setField("age", "42");
session.insert(person);Or there's another nicer way?
Thank you,
-Oleg Zenzin
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev