aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes client and lock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "client and lock" Watch "client and lock" New topic
Author

client and lock

cody monk
Greenhorn

Joined: May 15, 2011
Posts: 6
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
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

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)


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
jQuery in Action, 2nd edition
 
subject: client and lock