wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLy BIRD : record level locking vs file level locking 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 "URLy BIRD : record level locking vs file level locking" Watch "URLy BIRD : record level locking vs file level locking" New topic
Author

URLy BIRD : record level locking vs file level locking

jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
My instructions says:

What you must do
The following are the "top level" features that must be implemented:
1..
2 A data access system that provides record locking
3..


Further the interface insists

You must implement
public long lock(int recno)


I can accomplish the locking by record or file level locking. But does the two non functional requirements above, insist that I need to use Record level locking? Will I fail if I do File level locking?
[ December 16, 2005: Message edited by: jiju ka ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Hi Jiju,

At a functional (or business) level you must provide record level locking according to your instructions - both the explicit instruction you mentioned, and some implicit instructions (regarding concurrent multi user access).

So at a business-logic level, when I am in the process of booking record number 5 (for instance), I need to know that I have the ability to logically lock record number 5 so that no other client can book it. While it is logically locked, I can perform any business logic needed that requires the record to be locked.

As for physically locking the file itself (possibly via the java.nio.channels.FileLock class, it is worth noting the following warning in the API:
Whether or not a lock actually prevents another program from accessing the content of the locked region is system-dependent and therefore unspecified.


Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Thanks Andrew. It makes sense while thinking using the physical and logical views.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLy BIRD : record level locking vs file level locking