[rules-users] Defining facts declaratively with TypeDeclaration and assert facts from java

Edson Tirelli tirelli at post.com
Mon Feb 9 09:45:22 EST 2009


   Ronald,

   Last week I wrote the docs for TypeDeclaration. So, you may try the docs
first hand and provide me feedback! ;)

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-expert/html/ch06.html#d0e3047

   The API was promoted from drools-core to drools-api after M5 was
released, so you need trunk to use it.

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/

   Regarding your questions, I believe this is probably the easiest way of
doing it, but not the only one. Just to mention another way would be to
generate a JAXB domain model from your database and upload it as a jar to
Guvnor.

   If you want to dive into Drools internals and see how the classes are
generated, take a look at org.drools.factmodel.ClassDefinition in
drools-core as your starting point. From there you can navigate through the
code searching for the references. IMO though, you don't need to go down
this route.

   Regarding the pipeline, if you want to customize it for your needs, you
just need to create an intermediate step or use smooks to map from one model
into the other. I think mark did not added a step to map from an external
model into a type declared model yet. Contributions welcome.

   Hope this helps,
        Edson



2009/2/6 Ronald Brindl <rbrindl at thegoldensource.com>

> Referring to threads
> http://thread.gmane.org/gmane.comp.java.drools.devel/2860
>        Dynamic Facts: how to get jar wih Facts declared in drl
> http://thread.gmane.org/gmane.comp.java.drools.devel/2595
>        TypeDeclaration plugin heirarchy
>
> I am just in the process of evaluating the possibilities of using Drools.
>
> Our use case is the following:
> We have a dynamic metamodel, which gets generated from database during
> application initialisation phase.  Then a runtime model gets instantiated,
> which is fed from incoming messages (files, jms, etc.)
> Both models are highly generic, basically maps of maps (lists of lists, for
> model instances)
>
> Now, i would like to publish the metamodel to Guvnor as fact model, so that
> business rules users can use it there and define
>
> In the last 2 days i dived into the sources, read the mailing list entries
> above, documentation and so on, but i still don't have a clear vision on
> how to accomplish that.
>
> Our first approach was to use TypeDeclaration, i.e. to dynamically create
> DRL that defines the fact types as defined in our metamodel, but i don't
> have a clue on how to assert data for those types, since i don't have the
> resulting java classes available in Java.
> (There was also some confusion: in the documentation (M5) it says, bytecode
> is generated for declaratively defined Facts, but i could not find anything
> in the code, where this byte code is generated)
>
> Our next approach was to generate interfaces as Fact types and create
> proxies to access the data. This would also allow us to implement another
> use case, that demands access to messages already stored in the database
> with the same id as the incoming messages, and compare what fields are new
> and to provide merging of new and old data.
>
> I also had a quick look at the new Pipeline concept, but as far as i
> understand that, it builds on a statically defined FactModel.
>
> Then i dived a little bit more into the code and saw code generation for
> accessing Java class facts, which also might be a reasonable solution for
> us.
>
> However, what i was asking myself was, if there is some entry point for
> functionality like that, some existing API.
>
> Thank you,
> ron.
>
>
> --
> Ronald Brindl
> Sr. Software Developer
> Member of Architecture Team
> The Goldensource Corporation
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090209/31eab1ed/attachment.html 


More information about the rules-users mailing list