aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Locking question 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 "Locking question" Watch "Locking question" New topic
Author

Locking question

fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
I am working on B&S project, I only provide client with 2 methods:
- book(int rec)
- search(string[] criteria)

should I do locking on server or client? is the above method exposed to client enough?

Thanks in advance
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
In my opinion, you should do locking on server.
cuz you will need to do locking by implementing lock(int recNo) in Data class and this should be on server side. The client doesn't need to care about the record locking. You just expose the book method to client.Then book method will probably invoke lock()->update()->unlock(). This depends on your design.


SCEA, SCJD, SCDJWS, SCWCD, SCJP
Zhongbo Li
Greenhorn

Joined: Dec 06, 2003
Posts: 23
Server


SCJP,SCJD,软件设计师<br />Skype:mediumwave<br />QQ:85646604<br /><a href="http://www.yjping.com" target="_blank" rel="nofollow">http://www.yjping.com</a>
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
hi;


book(int rec)


who is the customer booking this recrod , i think you must pass additional
parameter customer number:

book(int rec, String eightDigitCustNumber)

also may be another clients delete this record during client view and another one create another record with different data in the same location
so the record number for new record will be the same and when the viewing
client want to book record he will book the new record that differ

Best regards.
Mohamed Darim.
fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
Originally posted by mohamed sulibi:
hi;



who is the customer booking this recrod , i think you must pass additional
parameter customer number:

book(int rec, String eightDigitCustNumber)

also may be another clients delete this record during client view and another one create another record with different data in the same location
so the record number for new record will be the same and when the viewing
client want to book record he will book the new record that differ

Best regards.
Mohamed Darim.


Thanks Mohamed, so client book the wrong record, is that acceptable?
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Originally posted by fei lin:


Thanks Mohamed, so client book the wrong record, is that acceptable?


Hi,

I think what Mohamed meant, is that you should make sure that the client holds the "latest" data of the record he wants to book. For instance, the client could be working on "old" data and I believe you should prevent him from modifying such record.

So, you could consider passing the original record and compare it to the database before allowing its update/booking.

But that's at the "service/Business" level, the Data layer does not care..

bye,
Alex
[ March 24, 2008: Message edited by: Alex Belisle Turcot ]
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
hi;

thank you Alex for your reply i mean exactly what you said.

best regards.
Mohamed Darim.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Locking question