• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about locking

 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While waiting for a reply to my previous question,I am going to post my next one(my due is next week).

I have the lock method with cookie.Since I cant find the owner of lock,my only choice is to make sure the proper use of API.
Do I have to make the book method from business layer as synchronized,to finish the job completely.
And also I dont know how to stop from deadlock(preventing the owner from getting other lock/same lock).


Thanks,
Ramya.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have the interface with a cookie, you can not identify which client locked which record. So you can not prevent a client from locking more than 1 record, and this scenario could result in a possible deadlock. I know of people passing with just describing these scenario in choices.txt and enforce proper use of the API in the javadoc comments (a client miust unlock a record first, before it can lock another one). If another developer doesn't use your API as described, it's his mistake and not your's.

Hope it helps!
Kind regards,
Roel
 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply.

Then it means I dont have to synchronize business method.

I followed the discussions here about overriding the RNF exception in update/delete methods from
sun interface.Now I realize that I can't do in my case.

Because there is no sure that udate will be called immediately after lock method,so I have to check the
availability again in my update/delete methods as in the original interface.


Thanks,
Ramya.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramya Ramalingam wrote:Because there is no sure that udate will be called immediately after lock method,so I have to check the
availability again in my update/delete methods as in the original interface.

When a record is locked by clientX, no other client than clientX should be able to update/delete this record. So if the record is successfully locked, the record will still be there, even if the update/delete method is invoked 15 minutes later So when a record does not exist anymore (because of deletion by another client), the lock method should throw a RNFE.
 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok. clear now! ...I think I am in last minute stress.


Thanks,
Ramya.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic