Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
frank sun
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11854
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
frank sun
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the signature of lock is:void lock(int recNo),unlock:void(int recNo)
Thanks!
Frank
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11854
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
frank sun
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks a lot, I have found some posts here to solve my questions.
Thanks for your reference!
Frank
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic