aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to produce the clientID? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to produce the clientID?" Watch "How to produce the clientID?" New topic
Author

How to produce the clientID?

Zhou Can
Ranch Hand

Joined: Sep 12, 2002
Posts: 34
I use the clientId in my design , But to my muddle is how to produce an unique clientID for every client.
Could u help me ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"Zhoucan"-
This is your third notice.
Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
[ December 04, 2002: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
I used new UID() on the server and return it to the client as confirmation id.
I hope it is good enough for the assignement.
Any other idea?


Charles.<br />(SCJD2)
jay denzel
Ranch Hand

Joined: Sep 18, 2002
Posts: 57
Hi,
I think the most widely used approach is to use the connection object itself as the client ID. This is the way I did it and I guess many others also. The idea is to issue a unique client connection object in remote mode using a RMI connection factory. This object reference is handed over until you access the database using the LockManager, the LockManager puts the object reference along with the record number in a Map.
Hope this helps.
jay
-----
SCJP
SCJD
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi there,
I worked quite a lot on this clientID work but I submitted my assignment with different design. And I was satisfied with my work when I got 51 out off 53 in server design. My approach was based on Spooler like tech. Apart from record no. being locked it also get spooled with the RecordSpooler class which implemented Spooler interface. This technique was helpfull in the case only that client was able to unlock the record who had actually acquired that lock. And if attempt was made by an connection who has not acquired a lock then that record will never be unlocked.
thank's
gurpreet
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
Jay,
I think the most widely used approach is to use the connection object itself as the client ID.

How do you get the connection object reference?
The return values of 'lookup' for two clients in my implementaion are equals. Please tell me how you force the server to return different objects for each client.
Thanks
Charles.
[ December 08, 2002: Message edited by: Charles Dupin ]
[ December 08, 2002: Message edited by: Charles Dupin ]
jay denzel
Ranch Hand

Joined: Sep 18, 2002
Posts: 57
Returning a new client connection object which can also be used as the client ID can be achieved by using a factory pattern.
This is the way I did it.
I had a RMI Connection factory object which is registered as a service. Each client trying to access the database uses a local connection factory which contacts the RMI connection factory to return a remote connection object. Every connection object (local or remote) implements a DataClient interface which holds all public methods of Data.
The returned object is the client ID, because each object is unique. The LockManager can use it for locking/unlocking. I used the client ID as the key in the LockManagers HashMap.
Hope this helps.
jay
------
SCJP
SCJD
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
Great
Thanks
Charles
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
You can also use the java.rmi.server.UID.
Hope it helps.


Regards,<br />Andrea<br /> <br /><a href="http://www.linkedin.com/in/andreagazzarini" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID : a.gazzarini@gmail.com<br /><a href="http://www.andreagazzarini.blogspot.com" target="_blank" rel="nofollow">My Blog</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to produce the clientID?