See below.<br><br><div class="gmail_quote">On 22 March 2012 17:25, lhorton <span dir="ltr"><<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
5.2.0.Final<br>
<br>
consider this simplified example, which has RMI calls to a service to<br>
getLocation()<br>
<br>
rule "example"<br>
when<br>
$p : Product( location != remoteService.getLocation("A") )<br>
then<br>
$p.setLocation( remoteService.getLocation("A") );<br>
end<br>
<br>
the above rule calls the remote method twice, once in the LHS to compare to<br>
a current value, and again in the RHS to set the value. I would like to<br>
capture the return value of the LHS call, to avoid making the call twice. I<br>
haven't been able to figure out the syntax to do this within the pattern.<br>
Here's one example of what I have tried:<br>
<br>
rule "example"<br>
when<br>
$p : Product( location != $loc : remoteService.getLocation("A") )<br>
then<br>
$p.setLocation( $loc );<br>
end<br>
<br>
Does anyone know the correct syntax to accomplish this? Or am I trying to<br>
do the impossible?<br></blockquote><div><br>With a single rule: yes, I think. However: <br><ol><li>At the outset, you know that a comparison with Location A is required.</li><li>If you have that firmly in your WM, you can compare and it's possible to use it on the RHS.</li>
</ol>This is reflected by the following rules:<br><br>rule example1<br>when<br> $p : Product( $mli: missingLocationId ) // that would be "A"<br> not Location( id == $mli ) // haven't RMI'd this yet<br>
then<br> Location loc = remoteService.getLocation( $mli );<br> insert( loc );<br>end<br><br>rule example2<br>when<br>
$p : Product( $mli: missingLocationId ) <br> $loc: Location( id == $mli )<br>
then<br>
$p.setLocation( $loc );<br>
end<br><br>The idea here is to let a RHS execution intervene to do the RMI once.<br><br>-W<br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Can-I-capture-the-result-of-an-RMI-call-within-a-pattern-tp3848873p3848873.html" target="_blank">http://drools.46999.n3.nabble.com/Can-I-capture-the-result-of-an-RMI-call-within-a-pattern-tp3848873p3848873.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>
</blockquote></div><br>