• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on lock/unlock implementation

 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my implementation of lock/unlock. I implemented lock/unlock in Data by using a reference of LockManager. I think this is a "generic" functionality, and it should be here.

I don't have a LocalData, if it is in local mode, I just passed a wrapper class of Data (with business logic such as bookFlight, but without lock-read-modify-unlock sequence). If it is in remote mode, I passed the RemoteDataImpl(I aslo implement bookFlight here, but with the sequence), another Data wrapper.
Thanks for your comments.
-Kevin
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I implemented lock/unlock in Data by using a reference of LockManager. I think this is a "generic" functionality, and it should be here.

Hmm, Data class was generic before you made it use your LockManager. Not anymore, -- if you want to replace your locking schema with something else, your (presumably generic) Data class has to change. So, here is a challenge for you, -- can your app use LockManager while you Data class knows nothing about it?
Eugene.
 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eugene-
I think the Data class is a reflection of the database(a file here), it should contains all the functinalities that a database needs: insert, delete, locking etc. Having a reference of LockManager won't affect it. But this is just my thought.
Actually, my question for this topic are:
1. Whether this implementation is correct? I have seen lots of people having LockManager and Datainterface in RemoteDataImpl, and applying lock schema there.
2. Is this the right place to apply business logic(the wrapper class)? I think it is the argument of fat-server vs. fat-client.
Again, thanks for your reponse.
-Kevin
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin,
Think about not having two different wrapper versions of Data for local and remote mode. Assuming that your design decision doesn't include locking in local mode, there is no need for the Data object to interact or know about the LockManager. The sequence below is used by many submissions in this forum:
DataImpl -> LockManager -> Data
Keep in mind that LockManager doesn't have to implement all the public methods in the Data class.
There are lot of things you can do in LockManager including a CleanupThread inner class to remove locks on records locked by dead clients.
 
Kevin Cao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai,
Thanks for your advice. After I read some threads from this forum, I convince myself to move the lock schema to RemoteDataImpl and move the business logic to client (Model of MVC).
Kevin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic