u can get that sb variable change in the client side if u use the inout
parameter in case of CORBA. The idl2java compiler generates holders for it
and then whatever manipulation is done on the server side gets reflected in
the client side via the orb. This feature is not there in RMI (correct me if
I am wrong).
Anamitra

-----Original Message-----
From: Michael Richmond [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 12, 2000 9:14 PM
To: [EMAIL PROTECTED]
Subject: Re: EJB/Java Inequity


"Previously, James Scott Stanlick said;"
> I had a college friend present a situation to me yesterday that seems
quite
> perplexing!  Consider the following two java classes that run in a single
> JVM:
>
> class Huh {
>
>         StringBuffer sb = new StringBuffer("Amit ");
>
>         public Huh() {
>                 super();
>                 Huh2 h2 = new Huh2();
>                 h2.passIt(sb);
>                 System.out.println(sb);
>         }
>         public static void main(String[] args) {
>                 new Huh();
>         }
> }
>
>
> class Huh2 {
>         public void passIt(StringBuffer sb) {
>                 sb.append(" Stanlick");
>         }
> }
>
> Output produced by class Huh is: Amit Stanlick.
>
> This suggests that the invoked method has the ability to modify the object
> passed to it as a parameter, which sounds very normal!  The problem is
where
> class Huh2 becomes a Session Bean.  Class Huh can obtain a remote
reference
> to Huh2 and fire the passIt(StringBuffer sb) method, however, the
> modification to the StringBuffer IS NOT reflected in Huh!  This seems to
> defy the Java way!  Can someone please explain?
>
> Thanks,
>
> J. Scott Stanlick
> Lead Software Engineer
> Enterprise Rent-A-Car

  The key is in how RMI works, in most cases it passes by value
  not by reference.  Ie the string buffer sent over the wire to
  the session bean is a copy which does not get returned.  Only
  actual return values get returned.

  The main problem is that the code above relies on a side effect
  of the Huh2 processing to achieve it's goal. What you need to
  do is EXPLICTLY return sb and assign it in Huh.

     ...michael

----
Michael Richmond
Information and Communication Sciences    e-mail: [EMAIL PROTECTED]
Macquarie University,  Australia          phone:  (+61 2) 9850 6346

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to