• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to ensure that no serialization of objects happens in Local mode

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
My question is pertaining to the local mode/remote mode requirement. I am using RMI.
In my implementation I do something like this

In the Client part
------------------
DataServer dataServer;
if(localMode){
dataServer = ServerManager.getDataServer();
}else if(remoteMode){
dataServer = lookUpUsingRmi();
}
//now start using the dataServer transparently


ServerManager
------------------
public void start(){
DataServer dataServer;
if(localMode){
dataServer = new DataServer();
}else if(remoteMode){
startRmiRegistry();
dataServer = new DataServer();
bindWithRmi(dataServer);
}
}

public DataServer getDataServer(){
return dataServer;
}


DataServer is the class which extends UnicastRemoteObject. Thus basically I am always creating an object of the DataServer.
The difference in the remote and local mode is that in the remote mode the server starts the rmi registry and binds the insatnce with it and the client must do a lookup from the rmi registry to get hold of the dataServer instance. Whereas in the standalone mode the client can just call a getter from the Sever manager and get the stored dataServer object.

Now my question is actually since I do not have much experience with rmi. I just want to ask you that with the above in mind do you think any serialization of objects will happen during the local mode ?
since I instantiate the class DataServer which extends from UnicastRemoteObject doesit mean some serialization will happen implicitely even though I am not even starting the rmi registry ?

Thanks in advance,
Chirag
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chirag,

Welcome to JavaRanch and this forum.

I deleted your earlier post, as it appears that this post contains everything that was in the other post and more. If I am wrong, and you want the other post put back, just say so.

If you ever want to edit a post you created, you can click on the icon that is above your post (there is one for each post in a topic - but you can only edit your own posts).

You do not need to worry about serialization happening behind the scenes with any of the classes you call. All you need to worry about is if you implicitly serialize some data.

But in case you are still concerned: RMI does not automatically serialize a class that extends UnicastRemoteObject - you would still have to tell RMI that the class can be serialized (by implementing the Serializable interface).

Regards, Andrew
 
Chirag Doshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Andrew, for the answer. Now it is clear to me.
About the duplicate post, that was an error while posting from me. You rightly deleted it, next time I will use the edit option.

I have a suggestion, for this forum can we have a preivew page where people can preview their posts see how it looks on screen and then finally submit.

Also I am not aware how we can post formatted code. The way my code looked on the page I thought no one would even try and read it.

Chirag
reply
    Bookmark Topic Watch Topic
  • New Topic