• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification on Record Lock without Cookie

 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,


I was reading one of your previous posts about how to ensure update/delete/unlock of a record by the client that locked it.

Lock without cookie

My assignment requires me to implement the locking without generating the cookies. Here's what I am trying to do as you depicted in the thread above.

1. I have a ConnectionFactory object that gives me unique instance of remote object.

2. I have a Data class that accesses the DB thro' a helper class(DataManager). I create a unique instance of a Data class for each client.

3. I am having a static collection object in the helper class (DataManager) that maintains each record that is being currently locked.

My question is this.

1. Does the above implementation ensure that a record can be unlocked only by the client that actually locked it in the first place?

2. Do we need to maintain a "key/value pair" kind of a collection object in the DataManager class that maintains the instance of Data class which locked it and the record being locked? So eveytime an unlock is requested, a check is made by passing the Data object reference to the DataManager class and validation is performed in DataManager class to know if this is indeed the Data object that locked a particular record in the DB.

Appreciate your inputs.

regards

Vrinda
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vrinda,

Hi Andrew,


I would recommend that initial posts should not be directed to an individual. There are lots of other people in this forum who might be able to answer your question and/or give differing opinions, but who might avoid the whole topic since it is addressed to an individual. Plus, addressing it to me means you are hoping that I have time to answer it (or even that I am still around - I might be on holiday / sick).

1. Does the above implementation ensure that a record can be unlocked only by the client that actually locked it in the first place?


The items you list are needed to meet this requirement, however by themselves they do not guarantee that the requirement is met. You also need the answer to your question below ...

2. Do we need to maintain a "key/value pair" kind of a collection object in the DataManager class that maintains the instance of Data class which locked it and the record being locked? So eveytime an unlock is requested, a check is made by passing the Data object reference to the DataManager class and validation is performed in DataManager class to know if this is indeed the Data object that locked a particular record in the DB.


This key/value collection, and the methods which check it, are required to guarantee that only the client who locked the record can work with it.

So you certainly have all the pieces of the puzzle .

You might not need to have your lock and unlock methods in the DataManager class - you might choose to have them in a separate LockManager class (in which case Data class is just a Fa´┐Żade to the other two classes). This is better from an OO perspective, since each class then has only a single responsibility. However you can leave your locking methods in either Data class or in DataManager if you so desire.

Regards, Andrew
 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

I apologize for addressing this mail to you as opposed to the group. I will take care of that in future. I would definitely appreciate inputs from all the members.

Also, thanks for your feedback and for confirming my understanding is correct.

regards

Vrinda
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic