• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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?
 
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 ]
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
 
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,
 
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
 
author
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
 
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
 
Hang a left on main. Then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic