File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes question about the update 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 "question about the update" Watch "question about the update" New topic
Author

question about the update

Jofer Chan
Ranch Hand

Joined: Sep 09, 2003
Posts: 49
Hi,everyone:
in the client,I book a record,the recNo and data passed to the server,
the server use the DBAccessImpl class to call the Data class,
in the Data class,the updateRecord method define follow:

my question is:
1. in the client,the record don't have the lockCookie,now ,it (the record) passed to the server,Does make the lockCookie with Random.nextLong() for this record in the DBAccessImpl class,then passed into the Data's updateRecord method?
2.in the Data's updateRecord method,it throw the SecurityException,
but access the file use the lock() -> updateRecord() -> unlock() mechanism,
in lock() throw the SecurityException,why does throw the SecurityException in the updateRecord method again?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Jofer,

1. in the client,the record don't have the lockCookie,now ,it (the record) passed to the server,Does make the lockCookie with Random.nextLong() for this record in the DBAccessImpl class,then passed into the Data's updateRecord method?

The lock() method returns the lockCookie which the client can then use in the update() method.

2.in the Data's updateRecord method,it throw the SecurityException,
but access the file use the lock() -> updateRecord() -> unlock() mechanism, in lock() throw the SecurityException,why does throw the SecurityException in the updateRecord method again?[/QB]


The SecurityException will occur if a client tried to bypass the call to lock(). So if a client tried to call updateRecord() without having first called lock() then the client will not have a lockCookie, and any value it tries to pass as the lockCookie will not match any value in the collection of locked records (even assuming the record is currently locked). So if a client tries to update a record without locking it first, you will throw the SecurityException from the updateRecord() method.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about the update