• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions of Max's example , plus registry.rebind().

 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max,
This is a follow up question of this post.
My first question is what is different between Registry.rebind() and Naming.rebind()?
Another question is regarding your example: You bound both FactoryImpl and RemoteDataImpl to rmiregistry using Factory pattern. What if I only bound RemoteDataImpl to the rmiregistry, since we only need one object(RemoteDataImpl) to register. Or this is a scability issue, say in FactoryImpl we can create RemoteData1Impl, RemoteData2Impl... Or unique ID? You register RemoteDataImpl with different name each everytime.
Also, as Mark posted, we create lockmanager in ConnectionFactory(FactoryImpl)only once, so the WeakHashMap variable will not necessary be "static". But in your example, you have the WeakHashMap in every RemoteDataImpl, so it should be "static". Do I understand this correct?
Thanks for answering my question.
Kevin
 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After i read several old posts regarding "unique clientID" and "ConnectionFactory". This is my understanding: A connectionFactory was created and bound to rmiregistry and will be accessed by all clients. Method getConnection was called, and a connection instance(DataInterface) was returned. I used to register every RemoteDataImpl per client call, and I had the same binding name all the time, so I really doubt this "uniqueness".
Max, I don't know whether this binding every RemoteDataImpl to registry necessary?
Thanks,
Kevin
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin,
Sorry it took me so long to get back to you.
Originally posted by Kevin Cao:
Max,
This is a follow up question of this post.
My first question is what is different between Registry.rebind() and Naming.rebind()?

essentially nothing, thought the method I demonstrated has the advantage of not forcing your client to have to start registry manually.

Another question is regarding your example: You bound both FactoryImpl and RemoteDataImpl to rmiregistry using Factory pattern. What if I only bound RemoteDataImpl to the rmiregistry, since we only need one object(RemoteDataImpl) to register. Or this is a scability issue, say in FactoryImpl we can create RemoteData1Impl, RemoteData2Impl... Or unique ID? You register RemoteDataImpl with different name each everytime.

Essentially correct. The factory is remote object, and clients bind to it to get their own instance of a remoteData object.

Also, as Mark posted, we create lockmanager in ConnectionFactory(FactoryImpl)only once, so the WeakHashMap variable will not necessary be "static". But in your example, you have the WeakHashMap in every RemoteDataImpl, so it should be "static". Do I understand this correct?

This example was designed to demonstrate an example of locking by using client refs in a weakHashMap: it's not particularly great code. The way I might do do it, in terms of the SCJD, is to have the each remoteData object have a (non-static) reference to a data object internally. The lock in remoteData would differ to that data member object. The data object would actually be the owner of the static weakHashMap.
Or you could have a ServiceProvider class, which locks, does stuff, and unlocks. There are a lot of solutions available here. The point I was focusing on was the actual locking.


Thanks for answering my question.
Kevin

Happy to help,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max,
Thanks for your response. Can you explain this more.
The way I might do do it, in terms of the SCJD, is to have the each remoteData object have a (non-static) reference to a data object internally. The lock in remoteData would differ to that data member object. The data object would actually be the owner of the static weakHashMap.

Thanks
Kevin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic