my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S 2.1.1 : Data Access & Locking Mechanism 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 "B&S 2.1.1 : Data Access & Locking Mechanism " Watch "B&S 2.1.1 : Data Access & Locking Mechanism " New topic
Author

B&S 2.1.1 : Data Access & Locking Mechanism

Mostafa Radwan
Greenhorn

Joined: Sep 09, 2003
Posts: 25
Hi Guys,
I am working on the design phase for the SCJD - B&S 2.1.1.

I just want to make sure that I understand something here and correct me if I am wrong.

There are two essential parts here:

1. Data Access: I usually planning on having some sort of an Access Manager that would handle data access tasks (I/O,DAO,DTO,..etc). That would make sure that multiple reads are possible and only one write for any record in the db file.


2. Locking Mechanism: That would make sure if a record is to be locked for booking or something like that, only the same client is able to unlock it .


Both of the above might be a combination of synchronized blocks and/or java.util.concurrent.locks. Is that correct ?

Thanks,
Mostafa

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5218
    
  12

Yes, you have 2 parts in the Data class: the real data access (reads and writes to a file) and a locking mechanism which should prevent a thread from updating/deleting a record if it doesn't own the lock on that record.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Mostafa Radwan
Greenhorn

Joined: Sep 09, 2003
Posts: 25
Thanks Roel for your prompt reply.

One last question, Is the data access (reads/writes) have to allow concurrent access as well ? I guess the answer is Yes.

So overall, there are two layers here one for data access(I/O) and the other for concurrent record locking/unlocking.

Thanks,
Mostafa
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5218
    
  12

Yes, reads and updates could occur concurrent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S 2.1.1 : Data Access & Locking Mechanism