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).<div>
In your rules, you can define globals for these services. Then, in the RHS of your rules, you can use these services.</div><div>For example:</div><div> </div><div> global com.some.package.EmailService emailService;</div>
<div><br></div><div> rule "A"</div><div> when</div><div> $s: Something()</div><div> then</div><div> emailService.sendEmail($s);</div><div> end <br clear="all"><br></div><div>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).</div>
<div><br></div><div>Best Regards,</div><div><br></div><div><br></div><div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Fri, Aug 12, 2011 at 4:37 AM, <a href="http://cross.cy">cross.cy</a> <span dir="ltr"><<a href="mailto:cross.cy.work@gmail.com">cross.cy.work@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, I only started using Guvnor recently. Just wonder if anyone could clarify<br>
one question. A good benefit of using Guvnor to manage rules is to decouple<br>
the rules from application code. However, the RHS of some rules may involve<br>
actions related to other logic classes in application. For example, there's<br>
a rule that sends out an email in the action, which uses methods defined<br>
elsewhere in the project, and these should not be known by Guvnor. So my<br>
solution for that is, create a declarative model containing an "Email" fact<br>
in Guvnor. When the rule fires, logical insert an "Email" object. And back<br>
in java code I'll try to check if there's an "Email" object created after<br>
the fireAllRules() call. If there is, call my email sending method.<br>
Is this the right way? If so, what's the best way to look for the newly<br>
created "Email" object in Java code? There are methods to getFactHandles()<br>
and getObjects(). Are they the area to look for?<br>
<br>
Any comment will be highly appreciated!<br>
<br>
Yu<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Dummy-question-from-a-new-comer-tp3248102p3248102.html" target="_blank">http://drools.46999.n3.nabble.com/Dummy-question-from-a-new-comer-tp3248102p3248102.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br></div>