File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Please comment on lock method implementation 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 "Please comment on lock method implementation" Watch "Please comment on lock method implementation" New topic

Please comment on lock method implementation

Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
Hi Guys,
After reading lots of thread and comment about lock method I end up with this implementation

1- Check if record numner is -1 then turn on a databaselocking flag and call lockDatabase method
2- If record number is positive then check if databaselocking flag is on then ignore request(I am not sure about this , please comment) and if databaselocking is off call lockRecord method
3- All lockDatabase do is to check if another client has databaseLockOwner object or clients has any lock of any records(looping through all records in hashmap and check for the owner(clientID)), if it's true then wait else assign the clientID to databaseLockOwner
4- lockRecord is a simple method to assign recordlock to client
I tried to make it as simple as I could , your comments will be really appreciated
It is sorta covered in the JavaRanch Style Guide.
subject: Please comment on lock method implementation
It's not a secret anymore!