GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How many instances are created? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How many instances are created?" Watch "How many instances are created?" New topic
Author

How many instances are created?

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I am a little bit confussed, and hoping you guys can help me out. I am working with RMI, and I don't know how many instances are created for Remote Objects. This is in regards to the Developer's exam, but as RMI in general, that's why I posted here.
OK, I have an object that is bound in the registry. If multiple clients lookup the object, does each client get their own version of the object, or is there still only one object? If there is only one object, how do I make the server create some kind of class on the server as a remote object, that stays on the server, but the client can call methods on.
Or is it like the RMI tutorial at Sun that has a Task object that is passed back to the server that is implementing and interface that has a method called executeTask().
Thanks for your help
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
I'm going to move this to the Developer's Certification for you.
-Peter
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Mark,
There is only one remote object, but each client gets its own proxy for it.
When the client "calls the remote object", it really calls the stub (a GoF proxy object). The stub causes the call information to be serialized and sent over the network. The RMI server receives this, deserializes it, and it ends up at the skeleton which then calls the "real" remote object. The value returned follows the opposite path.
- Peter
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

OK, then the proxy object for each client has a Collection(Hashtable) of locks for the client, and only that client.
Thanks
Mark Spritzler
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Mark Spritzler:
OK, then the proxy object for each client has a Collection(Hashtable) of locks for the client, and only that client.
No. The stub is completely transparent to you and has no visible state of its own, all it does is forward method calls to the "real" object. If your remote object has a eollection, there is just one copy of it: on the server.
- Peter
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Thanks Peter. I also found that out last night when I tested it at home.
I had two clients running, and they locked records 1 & 2for the first client, then 3 & 4 for the second client, and when I returned the Vector, it had all four record locks in it.
I will need this feature to keep track of all locks by all clients, but I guess I need a solution to ID them, like each client has it's own object, on the client, that tracks the records they have locked, so that they can only unlock their records.
Thanks
Mark
Chiji Nwankwo
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Hi,
Does anyone know how I can simulate multiple clients from the same machine, in order to test my lock and unlock mechanism is working properly.
Thanks,
Chiji


SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Hi Chiji, I am going to copy your post and make it a new thread, so that more people can respond to it too.
Here is the new thread.
Mark
[ June 26, 2002: Message edited by: Mark Spritzler ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many instances are created?