• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Record locking must be implemented using the methods public void lock(int) and public

 
Vince Zhang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I leave void lock(int) and public void unlock(int) methods blank, instead I implement the method in lockmanager class.
But in sun requirement: Record locking must be implemented using the methods public void lock(int) and public void unlock(int).
What should I do?
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do record and database locking in LockManager class and the signature for lock method is

the above method is called inside public void lock(int recNum)

In Local mode the body of public void lock(int recNum) is blank.
Garandi
[ January 15, 2003: Message edited by: Garandi Garandi ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vince, continue using the LockManager, it is avery elegant solution, and the requirements does not say that you have to have code in those methods. So you don't have to change anything.
Mark
 
Arjan Broer
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my design i have implemented the lock(int) and unlock(int) in Data. This implements simple straight forward locking of records.
I've also implemented a lockManager. The lockManager implements lock(int record, Object client) and unlock(int, Object). The LockManager simply administers the locks by keeping track of the lock owners in a Map.
So when a client requests a lock it calls the LockManager. Then the LockManager locks the record in Data on behalf of the client.
Regards,
 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arjan Broer:
... The lockManager implements lock(int record, Object client) and unlock(int, Object). The LockManager simply administers the locks by keeping track of the lock owners in a Map.
So when a client requests a lock it calls the LockManager. Then the LockManager locks the record in Data on behalf of the client.
Regards,

Hi Arjan,
I have implemented the same mechanism.
Did you already submitted your project to SUN?
Did you pass?
Kind regards
Jochen
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not Arjan, but I did the same and passed. Many others have done the same and passed. Implement with confidence. The requirements are for the lock() and unlock() methods in Data (and indirectly in DataInterface) ONLY. How you implement them "behind the scenes" is your business.
- Peter
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have also adopted the same approach where the lock and unlock in Data class call lock and unlock on LockManager class.
The DataAdapter calls on the methods in Data class.
The Client must connect to DataAdapter whether in local mode or remote mode. Now the problem is that the modify method in remote mode must have the implementation lock-read-modify-unlock, in local mode the implementation needed is read-modify. So the modify method in DataAdapter must have two different implementations depending on the mode.
The solution, I thought is to extend the Data class with another class NetworkData. The Data will have dummy lock and unlock whereas the NetworkData will have only two methods lock and unlock defined and implemented, these methods calls the methods in LockManager. So, the effect is when the DataAdapater calls lock-read-modify-unlock in local mode, it will encounter dummy lock and unlock methods in Data class whereas when the DataAdapter calls lock-read-modify-unlock on the NetworkData, it will encounter implemented lock and unlock in NetworkData but for modify, it will invoke the super class i.e Data class method.
Any comments ?
Thanks
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic