aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to map the to-be locked recordNo to the request client 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 to map the to-be locked recordNo to the request client" Watch "How to map the to-be locked recordNo to the request client" New topic
Author

How to map the to-be locked recordNo to the request client

frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
Hi,
It's about hotel room booking asignment.
I defined a HashTable to store the registered client and its locked record number(as the key), but, when the client trigger an event to do some action, and the controller listens for the event and forwards the request to the model, how can I know who it is requesting the action? how to map the to-be locked record number to the request client?
Best regards!
Frank
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Hi Frank,
What is the signatures of the lock() and modifyRecord() methods provided by Sun?
Are they the same as the Contractor assignment which seems to have a lockCookie? If so, that would appear to be the answer.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
the signature of lock is:void lock(int recNo),unlock:void(int recNo)
Thanks!
Frank
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Hi Frank,
Some ideas for you (by no means comprehensive)
If you are using sockets rather than RMI, then you can use the thread as your unique identifier.
If you are using RMI, you could provide alternative lock() and unlock() methods for RMI use which use a cookie the same as per the contractors assignment - you would then have to document fully why you are changing the signatures.
For some more ideas (some of which I like better than the suggestions above) look at this post.
In particular you might want to consider Mark Spritzler's solution - not one that I had even considered as being possible, but seeing what a high score he got, it is obviously a valid solution.
Regards, Andrew
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Frank, have you done a search on this forum for the "Connection" solution. This is basically you will have a Connection object that resides on the Server for each client. This object acts as the identifier for the client, on its behalf.
You will find many great posts on this solution.
Mark


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

Joined: Apr 11, 2003
Posts: 102
Hi,
Thanks a lot, I have found some posts here to solve my questions.
Thanks for your reference!
Frank
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to map the to-be locked recordNo to the request client