my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Lockmanager as inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Lockmanager as inner class" Watch "Lockmanager as inner class" New topic
Author

Lockmanager as inner class

Darien Chambers
Greenhorn

Joined: Oct 26, 2002
Posts: 4
Hi,
I've been reading this great forum and using it as a reference for my assignment. I wanted to get some comments about the design I'm considering. For the most part it should be pretty familiar as it combines the stuff I've read from books with things I've read here.
I'm going to create a Connection Factory which will handle whether we are going in network mode or local mode.
In local mode, the Connection Factory creates an instance to a DatabaseAdapter object. This object is just a simple facade to the Data class provided by Sun.
In remote mode, the Connection Factory looks up the remote object DatabaseRemoteImpl which implements the DatabaseAccess interface and extends Remote. The DatabaseRemoteImpl has all the remote methods defined.
When the controller wants to modify a record across the network, it calls the remote method modify. The DatabaseRemoteImpl has a reference to its own DatabaseAdapter object, which accesses Data. DatabaseRemoteImpl has an member class called LockManager which handles the locking. It puts the record into a synchronized list and then calls the DatabaseAdapter lock method (which in turn calls Data lock method). I modified the Data lock method to use a static list to store locked records.
The LockManager created by each DatabaseRemoteImpl will keep track of which records that client locked. The Data lock method (which I modified instead of extending) will keep track of all records locked.
Does this design sound okay or are there some obvious flaws/considerations I have to think about? Also, am I abstracting things too much by having that DatabaseAdapter object when I could just call Data directly? (The adapter provides an extra layer so that if things change in Data we don't have to worry about it in the upper layers, that's my initial reasoning anyway.)
Thanks! Knowing this forum, I think I will see some helpful responses.
Darien Chambers
Greenhorn

Joined: Oct 26, 2002
Posts: 4
Oh, another question, is it bad that the locking mechanism here is split between the Data method and the DatabaseRemoteImpl method?
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Lockmanager as inner class
 
Similar Threads
Problem of having 2 different Lock Managers
Passed with 95%
design comments ...
lock/unclock The correct question
Passed SCJD with 152/155