• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tracking client id for database lock

 
Marre Mask
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know a good way to implement this.
It's says in the assignment documentation that you should implement public void lock(int) and public void unlock(int). How I'm I then supposed to be able to track which client that is trying to lock and unlock the current record? Using the current threads name doesn't seem to be a adequate solution.
Any suggestions?
 
Rick Fortier
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages.
The other way is that some people modify the signatures of the lock/unlock methods.
 
Marre Mask
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick Fortier:
I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages.
The other way is that some people modify the signatures of the lock/unlock methods.

Are you really allowed to change the signature of lock(int) and unlock(int)? It's says in the instructions "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)".
 
Rick Fortier
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that it is best not to change the signatures. I did not. Others have and have passed.
There are two conflicting requirements, identify the connection for unlock is the same as lock, and the method signatures. Unless you come up with a complex answer, you will probably have to violate one or the other of these rules.
 
Akanimo Udoh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this as a solution to this. It works and is not complex.
Dont put any of the lock/unlock checking code in your Data class. Instead put this in whatever class you're using to do remote data access. Have a signature in that class that allows you to check who locks/unlocks appropriately and depending on that you can then call the non-checking lock/unlock methods in the Data class (ie at the server end). That way all remote lock/unlocks will be checked and local lock/unlocks don't really need checking.
Akanimo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic