[rules-users] Dummy question from a new comer

Esteban Aliverti esteban.aliverti at gmail.com
Fri Aug 12 03:07:15 EDT 2011


What you can do is to define something like a "Service Layer" to use in the
RHS of your rules. This layer could be composed of interfaces like
EmailService, SystemXService, SMSService, and so on. In guvnor, you only
need to upload the jar containing just the interfaces (of course you will
also need your Fact classes as well).
In your rules, you can define globals for these services. Then, in the RHS
of your rules, you can use these services.
For example:

    global com.some.package.EmailService emailService;

    rule "A"
    when
        $s: Something()
    then
        emailService.sendEmail($s);
    end

When you want to run these rules (that is when you create a ksession from
the kbase where they are), you need to provide a value for each of your
globals. This means that in your application you will need to have an
implementation for each of your services (of course).

Best Regards,



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Fri, Aug 12, 2011 at 4:37 AM, cross.cy <cross.cy.work at gmail.com> wrote:

> Hi, I only started using Guvnor recently. Just wonder if anyone could
> clarify
> one question. A good benefit of using Guvnor to manage rules is to decouple
> the rules from application code. However, the RHS of some rules may involve
> actions related to other logic classes in application. For example, there's
> a rule that sends out an email in the action, which uses methods defined
> elsewhere in the project, and these should not be known by Guvnor. So my
> solution for that is, create a declarative model containing an "Email" fact
> in Guvnor. When the rule fires, logical insert an "Email" object. And back
> in java code I'll try to check if there's an "Email" object created after
> the fireAllRules() call. If there is, call my email sending method.
> Is this the right way?  If so, what's the best way to look for the newly
> created "Email" object in Java code? There are methods to getFactHandles()
> and getObjects(). Are they the area to look for?
>
> Any comment will be highly appreciated!
>
> Yu
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Dummy-question-from-a-new-comer-tp3248102p3248102.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110812/4d5a4153/attachment.html 


More information about the rules-users mailing list