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
Joined: Oct 08, 2001
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 ]
Joined: Mar 20, 2002
How to manage the clientId in the server side, If apply the RMI Factory DP?