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.
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)