Repost: RMI Conundrum

Discussion in 'Java' started by VisionSet, Dec 30, 2005.

  1. VisionSet

    VisionSet Guest

    I send an object over RMI

    // can't modify myObject here, I don't want server to see modifications.
    myRemoteMethod(myObject);
    // too late to modify myObject here, I don't want to wait for transmission
    delay

    But I want to do something to myObject after it has been safely serialised
    (ie I don't want the server to know of the change I want to make). I don't
    want to have to wait until the remote method returns. If I fire the method
    off in its own thread then I can ascertain when that thread is running, but
    I can't be sure when myObject has been serialised.
    I realise I can get round this by cloning myObject but is there an
    alternative. Seems a pain to have to implement cloning throughout my object
    tree just for this, especially when serialisation is going to do it for me -
    just that I can't get at it - or can I?

    I think I can use Serialisation itself as a lower performance alternative to
    cloning.
    I'll probably do that if there is no alternative.

    TIA
    --
    Mike W
     
    VisionSet, Dec 30, 2005
    #1
    1. Advertising

  2. VisionSet wrote:
    > I send an object over RMI
    >
    > // can't modify myObject here, I don't want server to see modifications.
    > myRemoteMethod(myObject);
    > // too late to modify myObject here, I don't want to wait for transmission
    > delay
    >
    > But I want to do something to myObject after it has been safely serialised
    > (ie I don't want the server to know of the change I want to make). I don't
    > want to have to wait until the remote method returns. If I fire the method
    > off in its own thread then I can ascertain when that thread is running, but
    > I can't be sure when myObject has been serialised.
    > I realise I can get round this by cloning myObject but is there an
    > alternative. Seems a pain to have to implement cloning throughout my object
    > tree just for this, especially when serialisation is going to do it for me -
    > just that I can't get at it - or can I?


    If you want the client and server to see a different views of the
    transmitted (non-remotable) object, then you have a few choices. You
    could implement the readObject() and/or writeObject() methods to take
    control of the serialization behavior. Alternatively, you could
    implement Externalizable and take complete responsibility for the
    serialization and deserialization.

    Depending on the details of what you want to accomplish, however, you
    might also want to consider using a thin wrapper that provides the
    desired view to the client:

    myRemoteMethod(new ModifiedView(myObject));

    --
    John Bollinger
     
    John C. Bollinger, Dec 30, 2005
    #2
    1. Advertising

  3. John C. Bollinger wrote:
    > VisionSet wrote:
    > > I send an object over RMI
    > >
    > > // can't modify myObject here, I don't want server to see modifications.
    > > myRemoteMethod(myObject);
    > > // too late to modify myObject here, I don't want to wait for transmission
    > > delay
    > >
    > > But I want to do something to myObject after it has been safely serialised
    > > (ie I don't want the server to know of the change I want to make). I don't
    > > want to have to wait until the remote method returns. If I fire the method
    > > off in its own thread then I can ascertain when that thread is running, but
    > > I can't be sure when myObject has been serialised.
    > > I realise I can get round this by cloning myObject but is there an
    > > alternative. Seems a pain to have to implement cloning throughout my object
    > > tree just for this, especially when serialisation is going to do it for me -
    > > just that I can't get at it - or can I?

    >
    > If you want the client and server to see a different views of the
    > transmitted (non-remotable) object, then you have a few choices. You
    > could implement the readObject() and/or writeObject() methods to take
    > control of the serialization behavior. Alternatively, you could
    > implement Externalizable and take complete responsibility for the
    > serialization and deserialization.
    >
    > Depending on the details of what you want to accomplish, however, you
    > might also want to consider using a thin wrapper that provides the
    > desired view to the client:
    >
    > myRemoteMethod(new ModifiedView(myObject));
    >
    > --
    > John Bollinger
    >



    John, are related to the current President of Columbia University?
     
    puzzlecracker, Dec 30, 2005
    #3
  4. VisionSet

    E.J. Pitt Guest

    I guess the real question is, given that you want to do something in
    between the marshalling of your RMI call and the unmarshalling of its
    result, why you are using RMI at all? What you want can be accomplished
    naturally by out.writeObject(myObject); doSomethingLocalWith(myObject);
    result = in.readObject();
     
    E.J. Pitt, Dec 30, 2005
    #4
  5. [OT] The President of Columbia University

    puzzlecracker wrote:
    > John C. Bollinger wrote:


    [...]

    >>--
    >>John Bollinger
    >>

    >
    >
    >
    > John, are related to the current President of Columbia University?


    Not to my knowledge. The family has been in the U. S. of A. since
    before it was either U. or S., however, and it has branches (and variant
    spellings) everywhere. My particular branch is from the St. Louis and
    southeast Missouri region (since the 1830's), whereas President
    Bollinger of Columbia U. is from California.

    --
    John Bollinger
     
    John C. Bollinger, Dec 31, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Owen

    Clunky Cache Code Conundrum?

    Jim Owen, Jul 3, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    370
    dave wanta
    Jul 3, 2003
  2. Buu Nguyen

    RMI, JINI or RMI/IIOP

    Buu Nguyen, Aug 25, 2004, in forum: Java
    Replies:
    1
    Views:
    568
    Sudsy
    Aug 25, 2004
  3. JScoobyCed

    RMI Vs RMI over IIOP

    JScoobyCed, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    744
    Dag Sunde
    Jan 28, 2005
  4. Jan Schulze
    Replies:
    1
    Views:
    572
    Esmond Pitt
    Mar 26, 2005
  5. VisionSet

    RMI conundrum

    VisionSet, Dec 23, 2005, in forum: Java
    Replies:
    2
    Views:
    376
    VisionSet
    Jan 2, 2006
Loading...

Share This Page