Two Laptop Bag*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 4908
    
  10

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/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client and lock
 
Similar Threads
B&S Appropriate Use of Exception
thick client vs thin client
If JMS Server crashes, what happens to Standalone JMS Listener Client
Local vs Remote
Study Notes on Common Architecture