• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on lock/unlock implementation

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic