Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Repost: RMI Conundrum

Reply
Thread Tools

Repost: RMI Conundrum

 
 
VisionSet
Guest
Posts: n/a
 
      12-30-2005
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




 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      12-30-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
puzzlecracker
Guest
Posts: n/a
 
      12-30-2005

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
> (E-Mail Removed)



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

 
Reply With Quote
 
E.J. Pitt
Guest
Posts: n/a
 
      12-30-2005
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();
 
Reply With Quote
 
John C. Bollinger
Guest
Posts: n/a
 
      12-31-2005
puzzlecracker wrote:
> John C. Bollinger wrote:


[...]

>>--
>>John Bollinger
>>(E-Mail Removed)

>
>
>
> 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
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RMI conundrum VisionSet Java 2 01-02-2006 10:42 PM
Why does java.rmi.Naming not implement interface java.rmi.Registry? Jan Schulze Java 1 03-26-2005 07:45 AM
RMI Vs RMI over IIOP JScoobyCed Java 1 01-28-2005 09:54 AM
Bookmark Filing Conundrum mapmaker Firefox 2 12-21-2004 03:22 AM
RMI, JINI or RMI/IIOP Buu Nguyen Java 1 08-25-2004 11:28 AM



Advertisments