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'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 "results" 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 "in" 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"><<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>></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's step list: one step is named "one" and the other<br>
is named "two"<br>
<br>
the knowledge session has a global named "rmiService" that is a remote<br>
application service.<br>
knowledge session also has a global named "results" that is a List (this is<br>
my Box)<br>
<br>
there are two rules:<br>
<br>
rule1<br>
when<br>
$step : Step(name="one")<br>
then<br>
$step = rmiService.setJobName($step, "i belong to step one"); // sets the<br>
name of the step's job<br>
results.add($step);<br>
end<br>
<br>
rule2<br>
when<br>
$step : Step(name="two")<br>
then<br>
$step = rmiService.setJobName($step, "i belong to step two");<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 "one" has a parent job with name "I belong to<br>
step one" and step named "two" has a parent job with name "i belong to step<br>
two" - in other words, they no longer have the same parent Job.<br>
<br>
I can'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>