<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 &lt;tirelli@post.com&gt;">Edson Tirelli &lt;tirelli@post.com&gt;<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 &lt;tirelli@post.com&gt;</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 &lt;rules-users@lists.jboss.org&gt;</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 &lt;rules-users@lists.jboss.org&gt;</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>&nbsp; &nbsp;James,<br>
<br>
 &nbsp; 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>
 &nbsp; 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>
 &nbsp; Example:<br>
<br>
package my.package;<br>
<br>
global my.service.package.ServiceInvoker invoker;<br>
<br>
rule &quot;Cheese in stock&quot;<br>
when<br>
 &nbsp; &nbsp; $p : Person( $likes : likes )<br>
 &nbsp; &nbsp; $c : Cheese( type == $likes, quantity &gt; 0 )<br>
then<br>
 &nbsp; &nbsp;invoker.sendMessageToPerson( $p, &quot;Your prefered cheese <br>
(&quot;+$c.getType()+&quot;) is back in stock;&quot; );<br>
end<br>
<br>
 &nbsp; Inside your ServiceInvoker class you create the code to actually send <br>
the message (procedural code).<br>
<br>
 &nbsp; This is only one way of doing it, but it is usually what is done.<br>
<br>
 &nbsp; Hope it helps.<br>
<br>
 &nbsp; []s<br>
 &nbsp; Edson<br>
<br>
jdepaul wrote:<br>
<br>
&gt;I've done a little research since my first post and have been experimenting<br>
&gt;with the AgendaEventListener interface... &nbsp; I can register a component in<br>
&gt;WorkingMemory that will 'listen' and be notified afterEventFired event -<br>
&gt;this could be a good place from which to invoke my serivce, however, the<br>
&gt;problem I'm having is that the event delivered doesn't seem to pass the<br>
&gt;original Fact that caused the Event to fire, only the rule that got<br>
&gt;activated is sent... &nbsp;How could I get the Fact that caused this event to<br>
&gt;fire from that event object?<br>
&gt;<br>
&gt;James<br>
&gt;<br>
&gt;<br>
&gt; &nbsp;<br>
&gt;<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>