• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client and lock

 
cody monk
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been stuck with this issue for quite a while now: where should I handle the mapping between clients and database's record locks? And how can I distinguish clients in their requests to server? I appreciate any pointer/hint. Thank you.
 
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
cody monk wrote:where should I handle the mapping between clients and database's record locks?

That depends on your design. Some people created a few helper classes: one for the i/o operations (read, create,...) and another one for the record locking (lock, unlock) and just use the Data class as a facade. In this approach you keep that kind of data in the locking helper class. Other people (like me) just have everything in their Data class and then it's obvious you should keep this information in the Data class.

cody monk wrote:And how can I distinguish clients in their requests to server?

That depends on your interface you must implement. If you have one with a lockCookie, you use this cookie to identify the clients. If you don't have such a lockCookie in your interface you have to come up with something of your own to identify clients. If you choose sockets as a networking solution, you can make sure that the requests of a client are handled by the same thread (so you could use the thread id to identify the client). If you use RMI you don't have that guarantee and you have to hink of something else (e.g. setting the client id before each request it makes)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic