Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Server and clientID

 
Miguel Roque
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
I'me making my server and I have some problems with it. I have it as follows:

The connection to the database in the client side is made using a connection factory as follows:

And the RemoteServerImplementation is created as follows:

My question is, how can I get a unique clientID? I've tried some methods from RMI like getClientHost() and others, but if I open 2 clients i get the same values !
Thanks,
Miguel
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My question is, how can I get a unique clientID? I've tried some methods from RMI like getClientHost() and others, but if I open 2 clients i get the same values !

A common solution to this problem is to use a RMI Factory Pattern. Essentially, you bind a factory to the registry, the client gets the factory, invokes a method on that factory, and the factory creates another remote object which can be used to call the business methods. This remote object itself can then be used as a client identity. That is, all clients use the same object when they look up the registry, but each client gets a unique remote object to play with.
This "RMI factory" is such as clear and powerful pattern, that it is really hard to find a good alternative solution. That's why the most cowboys here take it as it is.
Eugene.
[ January 16, 2003: Message edited by: Eugene Kononov ]
 
Deedy Dee
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to manage the clientId in the server side, If apply the RMI Factory DP?

deedy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic