<html><body>
<p>Thanks Edson - <br>
<br>
Two questions:<br>
<br>
1) Is using Globals (as you mention below) same as using WorkingMemory.setApplicationData(myService) - or is this yet another way to do it. Is there a difference in terms of efficiency?<br>
<br>
2) Is there a way to get to the Fact that fired the event from the Event object passed in the AgendaEventListener.afterActivationFired(Event event) <br>
<br>
>From an efficiency and performance standpoint, which way would you recommend pursuing: EventListener invoking a service or service invoked from global Helper class in current WorkingMemory? Any guidance there would be appreciated.<br>
<br>
Thanks,<br>
James<br>
<br>
<br>
<br>
<img width="16" height="16" src="cid:1__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt="Inactive hide details for Edson Tirelli <tirelli@post.com>">Edson Tirelli <tirelli@post.com><br>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td style="background-image:url(cid:2__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com); background-repeat: no-repeat; " width="40%">
<ul>
<ul>
<ul>
<ul><b><font size="2">Edson Tirelli <tirelli@post.com></font></b><font size="2"> </font><br>
<font size="2">Sent by: rules-users-bounces@lists.jboss.org</font>
<p><font size="2">02/08/2007 02:31 PM</font>
<table border="1">
<tr valign="top"><td width="168" bgcolor="#FFFFFF"><div align="center"><font size="2">Please respond to<br>
Rules Users List <rules-users@lists.jboss.org></font></div></td></tr>
</table>
</ul>
</ul>
</ul>
</ul>
</td><td width="60%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">To</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">Rules Users List <rules-users@lists.jboss.org></font></td></tr>
<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">cc</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
</td></tr>
<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">Subject</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">Re: [rules-users] How to inovke a Service...</font></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="58"><img width="1" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""></td><td width="336"><img width="1" height="1" src="cid:3__=08BBF80BDFE94A758f9e8a93df938@us.ibm.com" border="0" alt=""></td></tr>
</table>
</td></tr>
</table>
<br>
<tt> James,<br>
<br>
The consequence and function blocks in a DRL file are transformed <br>
into a plain java method. It means you can do whatever you want and java <br>
allows. So, if you are for instance inside an application server, you <br>
cat get your JNDI context from there and do your stuff. Although, it is <br>
usually better to have helper classes doing procedural code and keep the <br>
consequence code clean to make rules maintance easier.<br>
<br>
So, for exaple, you can have a helper class that has the actual code <br>
to call the service you want and set it as a global for your rulebase. <br>
Then in the consequence you call this class method with the given <br>
paramenters.<br>
Example:<br>
<br>
package my.package;<br>
<br>
global my.service.package.ServiceInvoker invoker;<br>
<br>
rule "Cheese in stock"<br>
when<br>
$p : Person( $likes : likes )<br>
$c : Cheese( type == $likes, quantity > 0 )<br>
then<br>
invoker.sendMessageToPerson( $p, "Your prefered cheese <br>
("+$c.getType()+") is back in stock;" );<br>
end<br>
<br>
Inside your ServiceInvoker class you create the code to actually send <br>
the message (procedural code).<br>
<br>
This is only one way of doing it, but it is usually what is done.<br>
<br>
Hope it helps.<br>
<br>
[]s<br>
Edson<br>
<br>
jdepaul wrote:<br>
<br>
>I've done a little research since my first post and have been experimenting<br>
>with the AgendaEventListener interface... I can register a component in<br>
>WorkingMemory that will 'listen' and be notified afterEventFired event -<br>
>this could be a good place from which to invoke my serivce, however, the<br>
>problem I'm having is that the event delivered doesn't seem to pass the<br>
>original Fact that caused the Event to fire, only the rule that got<br>
>activated is sent... How could I get the Fact that caused this event to<br>
>fire from that event object?<br>
><br>
>James<br>
><br>
><br>
> <br>
><br>
<br>
<br>
-- <br>
Edson Tirelli<br>
Software Engineer - JBoss Rules Core Developer<br>
Office: +55 11 3124-6000<br>
Mobile: +55 11 9218-4151<br>
JBoss, a division of Red Hat @ www.jboss.com<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
rules-users@lists.jboss.org<br>
</tt><tt><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></tt><tt><br>
</tt><br>
</body></html>