There are two distinct ways of passing parameters: <a href="http://de.wikipedia.org/wiki/Wertparameter">call by value</a> and <a href="http://de.wikipedia.org/wiki/Referenzparameter">call by reference</a>. Passing Java objects blurs this distinction: the reference to the object is passed by value, but the called method can modify the referred object arbitrarily. The called method can <i>not</i> change the reference itself, i.e., the object remains the same.<br>
<br>But what happens during a RMI? The stub on the client&#39;s side behaves as you expect. But then the passed object is serialized, the data (not the object) is sent away, and, eventually, some data comes back and is deserialized into <i>another object. </i>And so this is, ultimately, a call by value, copying in to and out from the remotely called method.<br>
<br>Each setJobName RMI creates a clone of Step - so at the end of this little session you have 4 Step objects, the originals (still around as unchanged facts) and the clones in your &quot;results&quot; list.<br><br>-W<br>
<br><br>Method <br>   Step rmiService.setJobName( Step step,...) <br>could preserve object identity by copying all attributes of the deserialized object into the &quot;in&quot; object.<br><br>(Alternatively, the service could pass the entire object hierarchy to maintain integrity, but with parent and children being facts this would complicate matters considerably.)<br>
<br><br><br><div class="gmail_quote">On 5 August 2011 01:46, lhorton <span dir="ltr">&lt;<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I now have a more complex problem to solve involving this RMI issue and would<br>
like some advice.  I will state this as a simplified example to help explain<br>
the problem.<br>
<br>
Assume an object hierarchy:<br>
<br>
there is a Job, which has two attributes, a name and a list of Step objects.<br>
Each Step also has a name.<br>
<br>
before rules execute, create an instance of Job with no name.<br>
Add two Steps to the Job&#39;s step list:  one step is named &quot;one&quot; and the other<br>
is named &quot;two&quot;<br>
<br>
the knowledge session has a global named &quot;rmiService&quot; that is a remote<br>
application service.<br>
knowledge session also has a global named &quot;results&quot; that is a List (this is<br>
my Box)<br>
<br>
there are two rules:<br>
<br>
rule1<br>
when<br>
  $step : Step(name=&quot;one&quot;)<br>
then<br>
   $step = rmiService.setJobName($step, &quot;i belong to step one&quot;); // sets the<br>
name of the step&#39;s job<br>
   results.add($step);<br>
end<br>
<br>
rule2<br>
when<br>
  $step : Step(name=&quot;two&quot;)<br>
then<br>
   $step = rmiService.setJobName($step, &quot;i belong to step two&quot;);<br>
   results.add($step);<br>
end<br>
<br>
call execute() on the session, passing in the Step objects.<br>
<br>
assume that both rules fire.  after execution, the results global contains<br>
two objects: the step named &quot;one&quot; has a parent job with name &quot;I belong to<br>
step one&quot; and step named &quot;two&quot; has a parent job with name &quot;i belong to step<br>
two&quot; - in other words, they no longer have the same parent Job.<br>
<br>
I can&#39;t figure out how I can keep a hierarchy of objects updated when there<br>
are multiple RMI calls in the same session.<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3227109.html" target="_blank">http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3227109.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>