| 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: 4349
|
|
|
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: 4349
|
|
|
Yes, reads and updates could occur concurrent
|
 |
 |
|
|
subject: B&S 2.1.1 : Data Access & Locking Mechanism
|
|
|